Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

multiple selection in jsp using struts

Thread view: 
Vasu - 05 Oct 2006 15:31 GMT
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:options collection="userProp" labelProperty="label"
property="value" selected/>
        </logic:equal>

        <logic:notEqual name="userProp" property="isUserPropMatch" value="1">
        <html:options 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
VenuG - 05 Oct 2006 21:45 GMT
Hi Vasu,
           The following code should work....

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

Please let me know if you still have problems.

Venu

> Hi
>
[quoted text clipped - 46 lines]
>
> Vasu
Vasu - 09 Oct 2006 05:40 GMT
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:options collection="userProp" labelProperty="label"
property="value" selected/>
        </logic:equal>

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

> Hi Vasu,
>             The following code should work....
[quoted text clipped - 75 lines]
> >
> > Vasu


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.