struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dhananjay Makwana <>
Subject Struts2: Problem with form fields
Date Tue, 19 Mar 2013 10:02:40 GMT
Hi Everyone,

I am new to Struts2. I am creating a basic page where user can see login credentials for few

accounts (any type like Email, FB etc.) and if one of them is not present then add them. Each

account has a list of properties with a name and a string value (keeping it simple).

Now in my S2 application, I have an AccountList action which gets all accounts and puts them
in my 
user session. If an account is not added then it has a skeleton flag set. If this flag is
set then I 
want to set properties of that account and add it to the system. I have created AddAccountAction

Here's how my accountList.jsp looks like.

     <div class="accountList">
         <h4>Account AAA</h4>
         <s:set name="acct" value="#session.accounts.get('aaa')" />
         <div class="one half account padded">
                 <s:iterator value="">
                         <s:property value="name" />: <s:property value="value" default="[not_set]"
                 <s:form id="change_aaa_form" namespace="settings" action="addAccount"

                     <s:hidden name="acctId" value="aaa" />
                     <s:textfield label="%{'user.token'}" 
name="#session.accounts['aaa'].properties[0].value" ></s:textfield>
                     <s:textfield label="%{'user.secret'}" 
name="#session.accounts['aaa'].properties[1].value" ></s:textfield>
                     <s:submit key="Submit" />

My, AccountList action method looks like this

     public String execute() throws Exception {
         Map<String, Account> accts = AccountUtils.getInstance( getStore() ).getAccounts();
         getSession().put( "accounts", accts );
         return SUCCESS;

My Account class is a simple bean with a list of AccountProperty beans (with setters and getters).
     private String id;
     private String name;
     private List<AccountProperty> properties;
     private boolean isSkeleton;
     private String name;
     private String value;
     private boolean isPassword;

The AddAccountAction looks like this.

     public String execute() {
         Map<String, Account> accts = (Map<String, Account>) getSession().get(
"accounts" );
         Account a = accts.get( getAcctId() );
         if ( a == null )
             return ERROR;
         for ( AccountProperty p : a.getProperties()) {
             System.out.println( p );
         return SUCCESS;

My problem is that I cannot get the form to store the properties in my AddAccountAction. I
getting following warning on console.

2013-03-19 14:33:25,683 [http-8080-2] WARN com.opensymphony.xwork2.interceptor.ParametersInterceptor

- Parameter [#session.accounts['aaa'].properties[0].value] didn't match acceptedPattern pattern!
2013-03-19 14:33:25,704 [http-8080-2] ERROR 
com.opensymphony.xwork2.interceptor.ParametersInterceptor - Developer Notification (set 
struts.devMode to false to disable this message):
Unexpected Exception caught setting 'Submit' on 'class net.semandex.salsa.web.prm.AddAccountAction:

Error setting expression 'Submit' with value ['Submit', ]

I searched for this problem. I read [1] and [2] but somehow it is not working for me. I have
tried to create an empty Account with empty property list in my AddAcountAction class and

<s:textfield name="[0].value"

But I get the same error as above. I really want to keep my Account and AccountProperty classes

generic like this. Most of the S2 examples that I saw are talking about using specific property

names like "" with associated methods like getPerson().getName()


Thanks in advance,

View raw message