Hi,

I am getting errors from Parameters Interceptor while it tries to set
a value for a property.

My JSP is:

 <s:form theme="ajax" method="post" action="add_account"
namespace="/lsf/accounts" validate="true">
    <s:textfield required="true" label="Name" name="account.name" />
    <s:textfield label="UNIX GroupID" name="account.unixGroupId" />
    <s:submit value="Add" onclick="this.form.submit();" />
 </s:form>

The action is mapped to the method "String add()" of the following class:


@Validation
@Conversion
public class AccountAction extends BaseAction
{
   private Account account;
   private Long accountId;


   public void prepare() throws Exception
   {
      if ( accountId == null )
         account = new Account();
      else
         account = AccountManager.findById(accountId);
   }


   public String add() throws Exception
   {
      return SUCCESS;
   }


   public String update() throws Exception
   {
      return SUCCESS;
   }


   @VisitorFieldValidator(message = "")
   public Account getAccount()
   {
      return account;
   }


   public void setAccount(Account account)
   {
      this.account = account;
   }


   public Long getAccountId()
   {
      return accountId;
   }

   public void setAccountId(Long accountId)
   {
      this.accountId = accountId;
   }


The definition of the Account class:


@Validation
@Conversion
public class Account
{
   private Long id;
   private String name;
   private Long unixGroupId;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getName()
   {
      return name;
   }

   @RequiredStringValidator(message = "Account name is required", trim = true)
   public void setName(String name)
   {
      this.name = name;
   }

   public long getUnixGroupId()
   {
      return unixGroupId;
   }

   @TypeConversion(converter = "actions.NullLongConverter")
   @ConversionErrorFieldValidator(message = "UNIX GroupID must be in
the range 0..65535")
   @RegexFieldValidator( message = "UNIX GroupID must be in the range
0..65535", expression = "^\\s*(?:[0-9]{1,6})?\\s*$")
   public void setUnixGroupId(Long unixGroupId)
   {
      this.unixGroupId = unixGroupId;
   }
}

My validator:
public class NullLongConverter extends StrutsTypeConverter
{
   public Object convertFromString(Map context, String[] values, Class toClass)
   {
      Long val = null;

      if ( values != null && values[0] != null && !values[0].equals("") )
      {
         try
         {
            values[0].trim();
            val = Long.parseLong(values[0]);
            long v = val.longValue();
            if ( v < 0 || v > 65535 ) val = null;
         }
         catch( Exception ex ) { }
      }
      return val;
   }

   public String convertToString(Map context, Object o)
   {
      if ( o == null ) return null;
      else return o.toString();
   }
}


My action is using the paramsPrepareParamsStack.
I get this exceptions from

[ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor 28
Jan 2008 16:37:50] ParametersInterceptor - [setParameters]: Unexpected
Exception caught setting 'account.unixGroupId' on 'class
actions.lsf.accounts.AccountAction: Error setting expression
'account.unixGroupId' with value '12'

[ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor 28
Jan 2008 16:37:51] ParametersInterceptor - [setParameters
]: Unexpected Exception caught setting 'account.unixGroupId' on 'class
actions.lsf.accounts.AccountAction: Error setting expression
'account.unixGroupId' with value'[Ljava.lang.String;@52f9b2'



Any ideia why this is not working?

By the way, I also tried not using custom conversions / validations,
that is, using the built in conversion mechanisms. I get similar
errors.

Thanks


-- 
Filipe David Manana,
[EMAIL PROTECTED]

Obvious facts are like secrets to those not trained to see them.

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

Reply via email to