Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

struts problem

  • 13-05-2004 04:21PM
    #1
    Registered Users, Registered Users 2 Posts: 6,265 ✭✭✭


    hi all,
    i've got a question from a friend - any thoughts apprecieated.

    I have an Struts ActionForm called, say, "MyForm". My jsp page contains the following code:

    <!
    MyPage.jsp
    >
    ....
    <bean:define id="myForm" name="myForm" type="MyForm"/>
    <%
    //This Collection contains "Status" objects that implement "KeyValuePair" interface
    Collection statusList = myForm.getStatusList();
    long currentStatus = myForm.getCurrentStatus();
    pageContext.setAttribute( "statusList", statusList );
    %>

    <html:select property="statusId" styleClass="dropDown" value="???????">
    <html:options collection="statusList" property="statusId" labelProperty="status"/>
    </html:select>
    ....
    <!
    End MyPage.jsp
    >

    I want the select list to display whatever the current status is as the default value, using the "selected" attribute of the option tag. I know that you can set this with a literal string value, using the value="" attribute of the <html:select> tag (see above).
    This isn't any use to me though, as I must read the status from the database using the myForm.getCurrentStatus() method and assign it dynamically.

    Do you any way to do this?


Comments

  • Registered Users, Registered Users 2 Posts: 27 Harry Lime


    From what I remeber I think that is works like this...

    <html:select property="status">
    <html: options property="statuses"/>
    </html:select>

    where your ActionForm has a method getStatus() which returns the current status, and a method getStatuses() which returns an array of possible values.

    Sorry that I can't be more precise, but I think that's it.


Advertisement