Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > multiple selection in jsp using struts

Reply
Thread Tools

multiple selection in jsp using struts

 
 
Vasu
Guest
Posts: n/a
 
      10-05-2006
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">
<htmlptions collection="userProp" labelProperty="label"
property="value" selected/>
</logic:equal>

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

action.java
-------------------
String clickuserId = request.getParameter(CommonConstants.U_ID);
addUserForm.setUserPropositions(DAOFetchMasterReco rds.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

 
Reply With Quote
 
 
 
 
VenuG
Guest
Posts: n/a
 
      10-05-2006
Hi Vasu,
The following code should work....

<html:select property="selProposition" multiple="true"
name="addUserForm" onchange="showProposition()">
<htmlptions 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()">
<htmlptions collection="userProp"
labelProperty="label" property="value" />
</html:select>

Please let me know if you still have problems.


Venu


On Oct 5, 10:31 am, "Vasu" <(E-Mail Removed)> wrote:
> 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">
> <htmlptions collection="userProp" labelProperty="label"
> property="value" selected/>
> </logic:equal>
>
> <logic:notEqual name="userProp" property="isUserPropMatch" value="1">
> <htmlptions collection="userProp" labelProperty="label"
> property="value" />
> </logic:notEqual>
>
> action.java
> -------------------
> String clickuserId = request.getParameter(CommonConstants.U_ID);
> addUserForm.setUserPropositions(DAOFetchMasterReco rds.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


 
Reply With Quote
 
 
 
 
Vasu
Guest
Posts: n/a
 
      10-09-2006
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">
<htmlptions collection="userProp" labelProperty="label"
property="value" selected/>
</logic:equal>

<logic:notEqual name="userProp" property="isUserPropMatch" value="1">
<htmlptions 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

VenuG wrote:
> Hi Vasu,
> The following code should work....
>
> <html:select property="selProposition" multiple="true"
> name="addUserForm" onchange="showProposition()">
> <htmlptions 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()">
> <htmlptions collection="userProp"
> labelProperty="label" property="value" />
> </html:select>
>
> Please let me know if you still have problems.
>
>
> Venu
>
>
> On Oct 5, 10:31 am, "Vasu" <(E-Mail Removed)> wrote:
> > 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">
> > <htmlptions collection="userProp" labelProperty="label"
> > property="value" selected/>
> > </logic:equal>
> >
> > <logic:notEqual name="userProp" property="isUserPropMatch" value="1">
> > <htmlptions collection="userProp" labelProperty="label"
> > property="value" />
> > </logic:notEqual>
> >
> > action.java
> > -------------------
> > String clickuserId = request.getParameter(CommonConstants.U_ID);
> > addUserForm.setUserPropositions(DAOFetchMasterReco rds.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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple selection in jsp using struts Vasu Java 0 10-09-2006 01:21 PM
multiple selection in jsp Vasu Java 3 10-05-2006 12:02 PM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
Default selection using Struts html:select tag Lucas White Java 1 04-28-2004 01:57 PM
[JSP] Strings Constants from JSP using Struts tags Matthias Nietz Java 1 11-12-2003 04:32 PM



Advertisments