1) you have a mix of <html:... and regular HTML tags in your example. I
assume you're showing a combination of what's in your JSP and what gets
generated client-side by JavaScript? That shouldn't be a problem, but note
that using <html:text/> without an enclosing <html:form/> isn't valid.
2) if I understand you correctly, you're saying that in the action the form
is submitted to you want the connectedRoles property of the
ConnectRoleToUserForm instance contain the set of values the user selected
on the form, but you don't know how to code the setter for connectedRoles.
If so, see the FAQ on indexed properties [1].
L.
[1] http://struts.apache.org/faqs/indexedprops.html
Thomas Sundberg wrote:
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
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]