Hi!

I want to read values from a jsp page that contains something like this:

<form name="selectForm" action="connectRolesToUser.do">
        <form:text property="userName"/>
        <select name="availableRoles" size="14">
        <OPTION VALUE="1">role1
            <OPTION VALUE="2">role2
            <OPTION VALUE="3">role3
      </select>
      <html:submit value="Save"/>
</form>

I want the values to appear in an ActionForm so I can store them in a
database in a corresponding Action.

My action-mapping looks something like this:

        <action path="/connectRolesToUser"
        type="com.mypackage.ConnectRoleToUserAction"
            name="connectRoleToUserForm"
            scope="request"
            input="connectUserRole.jsp">
            <forward name="success" path="success.jsp"/>
        </action>

The form has been mapped properly in the form-beans section in
struts-config.xml.

My goal now is to read all the rows in the 'availableRoles' above and make
sure they can be found in the form 'connectRoleToUserForm'. The select
'connectRoleToUserForm' has been populated using a java script and another
select box to read stuff from.

The gui look something like this:

|----------|         |----------|
| Role1    |         | Role3    |
| Role2    |    ->   |          |
|          |    <-   |          | 
|          |         |          | 
|----------|         |----------|

I.e. two boxes where the values are moved between them. This logic works
with a simple java script. My problem is that I have spent a day looking for
examples where somebody reads the values from a html:select and access them
in a ActionForm without finding any example clear enough so I can understand
it.

I have seen a lot of half examples on DynaActions, but I assume that it
should be possible to use a ActionForm, and if so, how should the form be
written? I assume something like this:


public class ConnectRoleToUserForm extends ActionForm
{
    private String userName = null;
    private String[] connectedRoles = null;

    // with appropriate setters and getters. But I'm not sure how to write
them
    // Should the String[] be initiated in the constructor, and if so, how
do I know what size to set it to?
}

Anyone got any good suggestions or tip to offer?

/Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to