Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

struts problem

  • 13-05-2004 03: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