Default selection using Struts html:select tag

Discussion in 'Java' started by Lucas White, Apr 23, 2004.

  1. Lucas White

    Lucas White Guest

    Hi

    I'm trying to default a combo box to select a default value when my
    web page loads. The following code selects the index from the
    indexList with index id 27 because I hard-coded it:

    <html:select property="primaryIndexId" name="group" value="27">
    <html:eek:ption value="-1">&nbsp;</html:eek:ption>
    <html:eek:ptions collection="indexList" property="indexId"
    labelProperty="indexDesc" />
    </html:select>

    But when I try to soft code it to display the group's primary index,
    it does not work:

    <html:select property="primaryIndexId" name="group"
    value="primaryIndex.indexId">
    <html:eek:ption value="-1">&nbsp;</html:eek:ption>
    <html:eek:ptions collection="indexList" property="indexId"
    labelProperty="indexDesc" />
    </html:select>

    Any help would be appreciated.
     
    Lucas White, Apr 23, 2004
    #1
    1. Advertising

  2. Lucas White

    Yan Lijun Guest

    you need not to code like that
    <html:select property="primaryIndexId" name="group"
    value="primaryIndex.indexId">
    <html:eek:ption value="-1">&nbsp;</html:eek:ption>
    <html:eek:ptions collection="indexList" property="indexId"
    labelProperty="indexDesc" />
    </html:select>

    you simple only need to do is to set the property "primaryIndexId" in the
    actionform to what you want it to be in the action servlet

    ÔÚ 23 Apr 2004 14:02:09 -0700 ʱ, (Lucas White) дÁË:
    --

    >Hi
    >
    >I'm trying to default a combo box to select a default value when my
    >web page loads. The following code selects the index from the
    >indexList with index id 27 because I hard-coded it:
    >
    ><html:select property="primaryIndexId" name="group" value="27">
    > <html:eek:ption value="-1">&nbsp;</html:eek:ption>
    > <html:eek:ptions collection="indexList" property="indexId"
    >labelProperty="indexDesc" />
    ></html:select>
    >
    >But when I try to soft code it to display the group's primary index,
    >it does not work:
    >
    ><html:select property="primaryIndexId" name="group"
    >value="primaryIndex.indexId">
    > <html:eek:ption value="-1">&nbsp;</html:eek:ption>
    > <html:eek:ptions collection="indexList" property="indexId"
    >labelProperty="indexDesc" />
    ></html:select>
    >
    >Any help would be appreciated.



    /**
    /* Java Is Not Platform-independent.It Is The Platform!
    */
     
    Yan Lijun, Apr 28, 2004
    #2
    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. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,500
    Wendy S
    Jul 9, 2003
  2. LDM
    Replies:
    5
    Views:
    22,031
    Wendy S
    Oct 15, 2003
  3. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  4. J. Hall
    Replies:
    2
    Views:
    1,090
    Jeff Thies
    Apr 21, 2004
  5. Replies:
    1
    Views:
    401
    Andrew Thompson
    Nov 29, 2006
Loading...

Share This Page