Glad you found what you were looking for.
Yeah, the meta data merging is actually very powerful since it
basically automatically creates a dynamic proxy for all the
interfaces that the FooMetaData class implements and delegates the
calls to a dedicated instance of the FooMetaData class for every
individual instance of Foo.
Take care,
Geert
On 13 Oct 2006, at 21:28, John Lukar wrote:
Never mind folks.
I found a way to maintain my POJO autonomy and yet be able to add
dynamicly generated constraints for my Select drop down.
In my PersonElement, I had to use Constrained interface:
((Constrained) person).addConstraint( new ConstrainedProperty
( "personId").inList( identifiers ) );
Apparently Constrained is another one of the interfaces available
to your POJO through MetaData merging.
I find a more elegant way of doing this (adding dynamic content to
drop-down list) using this component by Steven contribution to
Wikki. (appreciate it much)
http://rifers.org/wiki/display/RIFE/Dynamic+select+using+dynamic
+constraints
Sorry for the noise. Somehow I missed that posting in the Wikki.
j.
On 10/13/06, John Lukar <[EMAIL PROTECTED]> wrote:
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
--
Geert Bevin
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users