multiple selection in jsp using struts

V

Vasu

Hi

i have used the following code to populate a list and have multiple
selection.
The scenario is when a user is clecked the proposiitons (some values)
associated with the user should get selelcted in the jsp in the mutiple
select list box.

edituser.jsp
--------------------

<bean:define id="userProp" name="addUserForm"
property="userPropositions" />

<html:select property="selProposition" multiple="true"
name="addUserForm" onchange="showProposition()">
<logic:equal name="userProp" property="isUserPropMatch" value="1">
<html:eek:ptions collection="userProp" labelProperty="label"
property="value" selected/>
</logic:equal>

<logic:notEqual name="userProp" property="isUserPropMatch" value="1">
<html:eek:ptions collection="userProp" labelProperty="label"
property="value" />
</logic:notEqual>

action.java
-------------------
String clickuserId = request.getParameter(CommonConstants.U_ID);
addUserForm.setUserPropositions(DAOFetchMasterRecords.getUserAssociatedProposition(clickuserId));
ArrayList user_proposition =
DAOFetchMasterRecords.getUserAssociatedProposition(clickuserId);

addUserForm is the name of the form where the jsp is present.

getUserAssociatedProposition is the method that gets the values from
the database and fills it in the jsp.

clickuserId is the userid of the user who has been selected.

the get and set method for userPropositions is available in the form
and for isUserPropMatch is at a util.java file.

the jsp page is getting loaded but the values are not getting selected.

kindly help.

thanks in advance.

Vasu
 
V

VenuG

Hi Vasu,
The following code should work....

<html:select property="selProposition" multiple="true"
name="addUserForm" onchange="showProposition()">
<html:eek:ptions collection="userProp"
labelProperty="label" property="value" />
</html:select>

make sure that userProp is in request.

if the above code doen't work try to set the userProp in page request
using following code.

<%
pageContext.setAttribute("userProp",
addUserForm.getUserPropositions(), PageContext.REQUEST_SCOPE);
%>

<html:select property="selProposition" multiple="true"
name="addUserForm" onchange="showProposition()">
<html:eek:ptions collection="userProp"
labelProperty="label" property="value" />
</html:select>

Please let me know if you still have problems.


Venu
 
V

Vasu

Hi Venu

thanks for ur help.

i ahve userProp in request.

<bean:define id="userProp" name="addUserForm"
property="userPropositions" />

<html:select property="selProposition" multiple="true"
name="addUserForm" onchange="showProposition()">
<logic:equal name="userProp" property="isUserPropMatch" value="1">
<html:eek:ptions collection="userProp" labelProperty="label"
property="value" selected/>
</logic:equal>

<logic:notEqual name="userProp" property="isUserPropMatch" value="1">
<html:eek:ptions collection="userProp" labelProperty="label"
property="value" />
</logic:notEqual>


</html:select>

i now have this code in my jsp which still does not work. i ahve
changed the query from abckend such that there is a field isMatch that
has a vlue "1" or "0" according to the propositions or the values. i
ahve been breaking my head wiht a couple of my friends at my workplace
too. Every one says that the code looks neat but wonder why i am not
able to fix it.

isUserPropMatch has get and set methods too.
kindly help.

i need help in using ur code:
<%
pageContext.setAttribute("userProp",
addUserForm.getUserPropositions(), PageContext.REQUEST_SCOPE);
%>

How do i set the userProp in jsp using this??? i ahve to get the
userProp from request and get the multiple selected values highlighted
in the lsit.

thanks
Vasu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top