Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Struts - dynamically making an option selected

843836Mar 3 2004 — edited Mar 4 2004
Hi,
I have a question for you guys.
I am creating a multiple selectable list box using struts.which is fine below is fine.
The problem comes in that the page is loaded for a specific user and I have to search the db for any roles for this user and if the user already have roles then I need to make this list box pre-select those roles in the list box.
I can not seem to get my hands on any syntax that will help me do this.

I was thinking along these lines
<bean:define id="roles" property="rolesList" name="login"/>
                            <html:select property="roles" style="width:120px;height:130px;" multiple="true">
                                <html:options collection="roles" property="roleId" labelProperty="name" />
                            </html:select>
the line of code above thats in bold, I was thinking, if I could pass that particular roleId to the form and then if this roleId has a role then return a string that will make this list option selected kinda like this

<html:options collection="rolesList" property="roleId" labelProperty="name" <bean:write name"formName" property="getSelected(roleId)"/> />

is there a way to get this done using struts????

I appriciate the guidance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2004
Added on Mar 3 2004
3 comments
499 views