Hi folks,
I am trying to generate the values of a Select drop down list dynamicaly in my Element by using
template.getBeanHandler().getFormBuilder().generateField() and adding the inList() constraint.
It doesn't seem to work, unless I add the constraint to the Bean object which requires my bean to "extend Validation".
I didn't want my POJO to do this. I have read docs and combed the mailing list. Below should work but doesn't.
example:
class Person {
String name;
Integer roleId; // Admin or Guess
}
class PersonElement extends Element {
public void initialize() {
Datasource datasource = getPropertyTyped("datasource", Datasource.class);
manager = new ContentQueryManager<Person>(datasource, Person.class );
person= manager.restore( getInputInt("personid"));
......
template = getHtmlTemplate(" person.edit");
}
public void processElement() {
template.addResourceBundle(new ListResourceBundle() {
public Object[][] getContents()
{
return new Object[][] {
{"roleId:1", "ADMIN"},
{"roleId:2", "GUESS"}
};
}});
template.getBeanHandler ().getFormBuilder().generateField(
template,
new ConstrainedProperty ( "roleId").inList("1","2"),
null,
null);
generateForm( template, person );
print(template);
}
In my form.html I use the following:
<r:v name="FORM:SELECT:roleId">id="roleId"</r:v>
This results in a empty Select drop down list.
If instead of using :
template.getBeanHandler().getFormBuilder().generateField(
template,
new ConstrainedProperty ( "roleId").inList("1","2"),
null,
null);
I use:
person.addConstraint( new ConstrainedProperty ( "roleid").inList("1","2") );
then the dynamic Select drop-down list is properly populated. But that requires that person extend Validation.
What am I missing ?
TIA to all.
j.
_______________________________________________ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users