How to keep the selectlist selected ?????

Discussion in 'Java' started by Gianni, Apr 9, 2004.

  1. Gianni

    Gianni Guest

    I have in my JSP a select box like this
    I can't find the way to keep what user selected in the next page


    <select name="selectedParmet" size="17"
    onchange="selezionagrandezza();">
    <logic:present name="parametri">
    <logic:iterate name="parametri" id="parametro"
    scope="session">
    <option value="<%=((it.sian.MIEDAX.ejb.MieaparmValue)parametro).getID_PARMET()%>"><bean:write
    name="parametro" property="DESCR_PARMET"/></option>
    </logic:iterate>
    </logic:present>
    </select>


    in the actionform class I have code like this:

    public String getSelectedParmet()

    {
    return this.selectedParmet;
    }
    public void setSelectedParmet(String selectedParmet)
    {
    this.selectedParmet = selectedParmet;
    }


    and in the relative action class I have a this:

    dsForm.setSelectedParmet(grandezzaselezionata);


    I expect to see selected the next page ... but nothing to do !
    Where is the error ??
    Thanks Grazie
     
    Gianni, Apr 9, 2004
    #1
    1. Advertising

  2. Gianni

    Andrew S. Guest

    (Gianni) wrote in message news:<>...
    > I have in my JSP a select box like this
    > I can't find the way to keep what user selected in the next page
    >
    >
    > <select name="selectedParmet" size="17"
    > onchange="selezionagrandezza();">
    > <logic:present name="parametri">
    > <logic:iterate name="parametri" id="parametro"
    > scope="session">
    > <option value="<%=((it.sian.MIEDAX.ejb.MieaparmValue)parametro).getID_PARMET()%>"><bean:write
    > name="parametro" property="DESCR_PARMET"/></option>
    > </logic:iterate>
    > </logic:present>
    > </select>
    >
    >
    > in the actionform class I have code like this:
    >
    > public String getSelectedParmet()
    >
    > {
    > return this.selectedParmet;
    > }
    > public void setSelectedParmet(String selectedParmet)
    > {
    > this.selectedParmet = selectedParmet;
    > }
    >
    >
    > and in the relative action class I have a this:
    >
    > dsForm.setSelectedParmet(grandezzaselezionata);
    >
    >
    > I expect to see selected the next page ... but nothing to do !
    > Where is the error ??
    > Thanks Grazie


    Use the <html:select> tag (which automatically does what you're trying
    to do)instead of manually creating the <select> tag.

    <html:select property="selectedParmet"
    onchange="selezionagrandezza();" >
    ....
    </html:select>

    Also, consider using the <html:eek:ptions> tag instead of you having to
    iterate and create the various <option>s.

    Andrew
     
    Andrew S., Apr 9, 2004
    #2
    1. Advertising

  3. Gianni

    Gianni Guest

    Select with Struts does not work ! Sigh !

    (Andrew S.) wrote in message news:<>...
    > (Gianni) wrote in message news:<>...
    > > I have in my JSP a select box like this
    > > I can't find the way to keep what user selected in the next page
    > >
    > >
    > > <select name="selectedParmet" size="17"
    > > onchange="selezionagrandezza();">
    > > <logic:present name="parametri">
    > > <logic:iterate name="parametri" id="parametro"
    > > scope="session">
    > > <option value="<%=((it.sian.MIEDAX.ejb.MieaparmValue)parametro).getID_PARMET()%>"><bean:write
    > > name="parametro" property="DESCR_PARMET"/></option>
    > > </logic:iterate>
    > > </logic:present>
    > > </select>
    > >
    > >
    > > in the actionform class I have code like this:
    > >
    > > public String getSelectedParmet()
    > >
    > > {
    > > return this.selectedParmet;
    > > }
    > > public void setSelectedParmet(String selectedParmet)
    > > {
    > > this.selectedParmet = selectedParmet;
    > > }
    > >
    > >
    > > and in the relative action class I have a this:
    > >
    > > dsForm.setSelectedParmet(grandezzaselezionata);
    > >
    > >
    > > I expect to see selected the next page ... but nothing to do !
    > > Where is the error ??
    > > Thanks Grazie

    >
    > Use the <html:select> tag (which automatically does what you're trying
    > to do)instead of manually creating the <select> tag.
    >
    > <html:select property="selectedParmet"
    > onchange="selezionagrandezza();" >
    > ...
    > </html:select>
    >
    > Also, consider using the <html:eek:ptions> tag instead of you having to
    > iterate and create the various <option>s.
    >
    > Andrew


    Im trying to use the Struts select tag to keep the optionlist
    selected.
    if I use the html tag select everything works
    if I use the Struts select and option tags I get this error:

    URI richiesta:/bdan/MIEDAL060.jsp



    Eccezione:
    java.lang.NullPointerException
    at oracle.jsp.parse.OpenJspAVInfo.setValue(OpenJspAVInfo.java:353)
    at oracle.jsp.parse.OpenJspTagHandler.processAttributeValue(OpenJspTagHandler.java:179)
    at oracle.jsp.parse.JspParseTag.parse(JspParseTag.java:661)
    at oracle.jsp.parse.OpenJspTagHandler.parse(OpenJspTagHandler.java:467)
    at oracle.jsp.parse.JspParseTag.parseNextTag(JspParseTag.java:548)




    <!-- Select without Struts IT WORKS !!!

    <select name ="selectedVarmet" size="17" multiple
    onchange="aggiorna();">
    <logic:iterate name="varmeteo" id="varmeteo" scope="session">
    <option value="<%=((it.sian.MIEDAX.ejb.MieavarmValue)varmeteo).getCOD_VARMET()%>"><bean:write
    name="varmeteo" property="DESCR_VARMET"/></option>
    </logic:iterate>
    </select>
    The next is the select with Struts DOES NOT WORK !!!!
    -->

    <html:select name ="selectedVarmet" size="17" multiple
    onchange="aggiorna();">
    <logic:present name="varmeteo">
    <logic:iterate name="varmeteo" id="varmeteo" scope="session">
    <html:eek:ption value="<%=((it.sian.MIEDAX.ejb.MieavarmValue)varmeteo).getCOD_VARMET()%>"><bean:write
    name="varmeteo" property="DESCR_VARMET"/></html:eek:ption>
    </logic:iterate>
    </logic:present>
    </html:select>



    Please help ! What do I do wrong ?
    Gianni
     
    Gianni, Apr 19, 2004
    #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. shapper

    Create SelectList

    shapper, Sep 7, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    760
    bruce barker
    Sep 8, 2008
  2. rodchar

    asp.net mvc SelectList help

    rodchar, Sep 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    1,870
    rodchar
    Sep 30, 2009
  3. jwcooper

    Mechanize SelectList Issue

    jwcooper, Mar 20, 2007, in forum: Ruby
    Replies:
    1
    Views:
    160
    jwcooper
    Mar 21, 2007
  4. Giel Raijmakers

    popup after selection from selectlist

    Giel Raijmakers, Jan 4, 2008, in forum: Ruby
    Replies:
    0
    Views:
    109
    Giel Raijmakers
    Jan 4, 2008
  5. hisan
    Replies:
    1
    Views:
    1,413
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page