|
#1
|
|||
|
|||
|
I'm trying to span a search form over two cells in an HLayout. Four fields on one side and four on the other. I'm using ValuesManager as in the example in the Showcase, but when I attempt to recreate the call from the button to filter a datasourceI have notices that the getValuesAsCriteria is not part of Values Manager ? I assumed that it would take the place of the DynamicForm in this splitting instance ?
Old code with a single Form: Code:
searchButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (myForm.validate()) {
myListGrid.filterData(myForm.getValuesAsCriteria());
}
}
});
Code:
searchButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (valuesManager.validate()) {
myListGrid.filterData(valuesManager.getValuesAsCriteria()); // err?
}
}
});
Al |
|
#2
|
|||
|
|||
|
We'll that add API, in the meantime, manually converting to Criteria is required.
|
|
#3
|
|||
|
|||
|
Understood. Will do.
There appears to be one further issue with the ValueManager which you may want to look into. If I have a / character in the name of a form item it breaks the Values Map in the ValueManager, as follows Note: the DynamicForm works perfectly with / in the field name, this is only an issue in the ValueManager. Code:
TextItem campusTextItem = new TextItem();
campusTextItem.setName("institute/campus");
...
searchButtonItem.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (vm.validate()) {
Criteria criteria = new Criteria();
Map formValues = vm.getValues();
Iterator it = formValues.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
GWT.log("VM Keys: " + pairs.getKey() + " = " + pairs.getValue());
criteria.addCriteria((String)pairs.getKey() ,(String)pairs.getValue());
}
myListGrid.filterData(criteria);
}
}
});
Code:
VM Keys: institute = [object Object] Code:
TextItem campusTextItem = new TextItem();
campusTextItem.setName("institute_campus");
...
searchButtonItem.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (vm.validate()) {
Criteria criteria = new Criteria();
Map formValues = vm.getValues();
Iterator it = formValues.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
criteria.addCriteria(pairs.getKey().toString().replace('_','/') ,(String)pairs.getValue());
GWT.log("VM Keys: " + pairs.getKey() + " = " + pairs.getValue());
}
myListGrid.filterData(criteria);
}
}
});
Code:
VM Keys: institute_campus = abc123 |
|
#4
|
|||
|
|||
|
FormItem.name in general must be an identifier, by luck you have not yet hit the many things your "/" would break. This will be not be changed.
|
|
#5
|
|||
|
|||
|
Quote:
For convenience I am using the xpath path to the source element in the name and this is working well in our use case. I can work around this limitation in ValueManager as shown in the sample, but I see no reason to have DynamicForm and ValueManager behave differently? Can't we simply have ValueManager mirror DynamicForm as the documentation suggests and "developer beware" if the client chooses to go down this route ? Out of interest what other aspects of SmartClient would the "/" break ? Your comment sounds quite ominous but provides no explanation. |
|
#6
|
|||
|
|||
|
Again, it is considered a usage error in both DynamicForm and ValuesManager. The fact that you haven't hit any of the problems it causes does not mean it's supported - it isn't.
|
|
#7
|
|||
|
|||
|
Quote:
|
|
#8
|
|||
|
|||
|
Maybe because "/" is a special character in XPath is the reason.
|
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
|||
|
|||
|
Any success on this one? Or anything like Evaluator.parseAdvancedCriteria(map)?
|