Hi David,
it will not generate the select list if your property hasn't got an
"inList" constraint.
Alternatively, you can generate the field explicitly with this method:
http://rifers.org/docs/api/com/uwyn/rife/site/
FormBuilder.html#generateField(com.uwyn.rife.template.Template,%
20com.uwyn.rife.site.ConstrainedProperty,%20java.lang.String[],%
20java.lang.String)
Hope this helps.
Best regards,
Geert
On 23-feb-06, at 13:45, David Herbert wrote:
Hello,
I am having some trouble with getting a <select multiple> HTML element
working. My application is a user manager where I want to dynamically
populate selection lists according to the rights of the currently
logged
in user. I have successfully got past logging in and currently
have my
"add a new user" empty form page coming up.
My template has a couple of select lists thus:
<tr>
<th align="left">User roles</th>
<td><!--V 'FORM:SELECT:roles'-->size="6" multiple<!--/V--></td>
</tr>
<!--V 'ERRORS:roles'/-->
<tr>
<th align="left">Admin area</th>
<td><!--V 'FORM:SELECT:admin_area_ref'/--></td>
</tr>
<!--V 'ERRORS:admin_area_ref'/-->
The second of these comes up perfectly populated from a database table
with values and captions as expected. The multiple one comes up as an
empty single-value dropdown list. It appears the "multiple size=6"
attributes aren't being noticed.
I'm populating the two lists via resource bundles in my AddUser.java
implementation class thus:
/* Populate select list for admin areas */
template.addResourceBundle(
new ListResourceBundle() {
public Object[][] getContents() {
AdminAreaManager aaMgr = new AdminAreaManager();
return( aaMgr.getAdminAreasResourceBundle() );
}
} );
/* Populate select list for user roles */
template.addResourceBundle(
new ListResourceBundle() {
public Object[][] getContents() {
RoleManager rlMgr = new RoleManager();
return( rlMgr.getRolesResourceBundle() );
}
} );
The first of these works perfectly. The second doesn't seem to work
with anything despite an Object[][] correctly populated coming back
from
getRolesResourceBundle(). If I change the FORM:SELECT:roles to the
raw HTML I do at least get a multiple select list rendered, though
still
without content. The constraints I am applying in the submission
bean (which of course isn't present for an initial add user where
no submission has happened) are:
addConstraint( new ConstrainedProperty( "admin_area_ref" ).notNull
( true
).notEmpty( true ).inList( adminAreas ) );
addRule( new RolesValidationRule( "roles" ) );
The rule simply has a validate() method which checks the bean
property value (assumed a String array - see below) against the
roles table.
What am I doing wrong here?
A subsidiary question - for HTML elements like a multiple select
list, I
assume the parameter eventually passed to me is mapped onto a Java
String array? So that the getRoles() and setRoles() methods in the
submission bean should be working with String arrays?
Thanks,
David Herbert.
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users
--
Geert Bevin Uwyn bvba
"Use what you need" Avenue de Scailmont 34
http://www.uwyn.com 7170 Manage, Belgium
gbevin[remove] at uwyn dot com Tel +32 64 84 80 03
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users