Streuts: html:select not being updated properly in DynaActionValidatorForm

Discussion in 'Java' started by Thomas 'Skip' Hollowell, May 20, 2004.

  1. <html:form action="dynAdminGroupMaint">
    <html:select property="parmGroup" onchange="this.form.submit();">
    <option>
    <c:forEach var="group" items="${allGroups}">
    <option value="<c:eek:ut value="${group.id}"/>">
    <c:eek:ut value="${group.name}"/>
    </option>
    </c:forEach>
    </html:select>
    </html:form>

    I would expect that the select is not being upated with the selected
    value because I am not using an <html:eek:ption> tag, just the plain
    <option> tag. But I get errors out the wazoo when I try the following:

    <html:eek:ption value="<c:eek:ut value="${group.id}"/>">
    <c:eek:ut value="${group.name}"/>
    </html:eek:ption>

    It does not like the ${group_id} in the option value parameter.

    Any ideas how I can get around this? I want to parse the list and
    display the list values in the select box, and then after submitting the
    form, display ther select box with the selected value higglighted.

    Thanks

    Skip.
    Thomas 'Skip' Hollowell, May 20, 2004
    #1
    1. Advertising

  2. Thomas 'Skip' Hollowell

    Sudsy Guest

    Thomas 'Skip' Hollowell wrote:
    > <html:form action="dynAdminGroupMaint">
    > <html:select property="parmGroup" onchange="this.form.submit();">
    > <option>
    > <c:forEach var="group" items="${allGroups}">
    > <option value="<c:eek:ut value="${group.id}"/>">
    > <c:eek:ut value="${group.name}"/>
    > </option>
    > </c:forEach>
    > </html:select>
    > </html:form>


    Grouping is wrong. Note the beginning and end tags of the option:
    one is outside the loop while the other is inside.

    > I would expect that the select is not being upated with the selected
    > value because I am not using an <html:eek:ption> tag, just the plain
    > <option> tag. But I get errors out the wazoo when I try the following:
    >
    > <html:eek:ption value="<c:eek:ut value="${group.id}"/>">
    > <c:eek:ut value="${group.name}"/>
    > </html:eek:ption>


    You're nesting quotes. Try this:
    <html:eek:ption value='<c:eek:ut value="${group.id}"/>' >
    (or swap the single and double quotes and try again)

    For more sophisticated apps, try this article:
    <http://www.sudsy.net/technology/struts-advanced.html>
    Sudsy, May 20, 2004
    #2
    1. Advertising

  3. Sudsy wrote:

    >
    > Grouping is wrong. Note the beginning and end tags of the option:
    > one is outside the loop while the other is inside.


    The grouping is ok, I have one blank option in there (no close option
    tag) and then the options with data.
    >
    >> I would expect that the select is not being upated with the selected
    >> value because I am not using an <html:eek:ption> tag, just the plain
    >> <option> tag. But I get errors out the wazoo when I try the following:
    >>
    >> <html:eek:ption value="<c:eek:ut value="${group.id}"/>">
    >> <c:eek:ut value="${group.name}"/>
    >> </html:eek:ption>

    >
    >

    The quoting was a bit doubled up, but changing the inner double quotes
    to singles didn't help, or changing the outers. I have a feeling there
    is a more straightforward way to tackle something like this, but I just
    can't grasp it at the moment. I have bookmarked your page though, it
    has quite a few nice tricks to remember.


    > You're nesting quotes. Try this:
    > <html:eek:ption value='<c:eek:ut value="${group.id}"/>' >
    > (or swap the single and double quotes and try again)
    >
    > For more sophisticated apps, try this article:
    > <http://www.sudsy.net/technology/struts-advanced.html>
    >
    Thomas 'Skip' Hollowell, May 20, 2004
    #3
  4. Sudsy <> wrote in message news:<>...
    > Thomas 'Skip' Hollowell wrote:
    > > <html:form action="dynAdminGroupMaint">
    > > <html:select property="parmGroup" onchange="this.form.submit();">
    > > <option>
    > > <c:forEach var="group" items="${allGroups}">
    > > <option value="<c:eek:ut value="${group.id}"/>">
    > > <c:eek:ut value="${group.name}"/>
    > > </option>
    > > </c:forEach>
    > > </html:select>
    > > </html:form>

    >
    > Grouping is wrong. Note the beginning and end tags of the option:
    > one is outside the loop while the other is inside.


    Although the grouping is wrong, it has no bearing on the problem.
    Instead, you must make sure that the form bean for the
    "dynaAdminGroupMain" action includes a property that is the same name
    as the select element property.

    You might also use the the struts <html:eek:ptionsCollection> tag instead
    of the <c:foreach> loop here.

    >
    > > I would expect that the select is not being upated with the selected
    > > value because I am not using an <html:eek:ption> tag, just the plain
    > > <option> tag. But I get errors out the wazoo when I try the following:
    > >
    > > <html:eek:ption value="<c:eek:ut value="${group.id}"/>">
    > > <c:eek:ut value="${group.name}"/>
    > > </html:eek:ption>

    >
    > You're nesting quotes. Try this:
    > <html:eek:ption value='<c:eek:ut value="${group.id}"/>' >
    > (or swap the single and double quotes and try again)
    >


    The quotes are in no way nested. Note that the <c:eek:ut> thingy inside
    the option value attribute is a JSP tag and will be processed before
    the HTML is sent to the client (i.e. the double quotes around the
    ${group.id} reference will not be present when the HTML is processed
    by the client).

    > For more sophisticated apps, try this article:
    > <http://www.sudsy.net/technology/struts-advanced.html>
    David W. Burhans, May 21, 2004
    #4
    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. bill yeager

    selectedindex value not being updated

    bill yeager, Oct 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    373
    carlos medina
    Oct 15, 2003
  2. Digital Puer
    Replies:
    3
    Views:
    443
    Mike Schilling
    Mar 15, 2006
  3. Cirene
    Replies:
    4
    Views:
    274
    Cirene
    May 18, 2008
  4. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    411
    Dmitry Korolyov
    Sep 22, 2003
  5. FAQ server
    Replies:
    10
    Views:
    189
    Thomas 'PointedEars' Lahn
    Nov 27, 2007
Loading...

Share This Page