multiple selection in jsp using struts

Discussion in 'Java' started by Vasu, Oct 5, 2006.

  1. Vasu

    Vasu Guest

    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
     
    Vasu, Oct 5, 2006
    #1
    1. Advertising

  2. Vasu

    VenuG Guest

    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


    On Oct 5, 10:31 am, "Vasu" <> 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">
    > <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
     
    VenuG, Oct 5, 2006
    #2
    1. Advertising

  3. Vasu

    Vasu Guest

    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

    VenuG wrote:
    > 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
    >
    >
    > On Oct 5, 10:31 am, "Vasu" <> 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">
    > > <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
     
    Vasu, Oct 9, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Nietz
    Replies:
    1
    Views:
    3,457
    VisionSet
    Nov 12, 2003
  2. Lucas White
    Replies:
    1
    Views:
    10,766
    Yan Lijun
    Apr 28, 2004
  3. Replies:
    0
    Views:
    4,397
  4. Vasu

    multiple selection in jsp

    Vasu, Sep 8, 2006, in forum: Java
    Replies:
    3
    Views:
    1,621
  5. Vasu
    Replies:
    0
    Views:
    557
Loading...

Share This Page