You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Security Management <li...@secmgmt.com> on 2009/04/07 16:45:56 UTC

Textfield populated from java.lang.Integer

I have the following form:

<s:form action="saveRuleName" method="POST">
<s:textfield key="ruleName" name="rule.ruleName" required="true" />
<s:textfield key="ruleDays" name="rule.ruleDays" required="true" size="4" />


I have the following method in the Action class that runs before this:

public IRule getRule()
{
    return this.r;
}

Now, IRule has the following:

public String getRuleName();
public void setRuleName(String n);

public Integer getRuleDays();
public void setRuleDays(Integer i);        

In the form, rule.ruleName works fine.  rule.ruleDays does not.  Is there
something special to do because it's an Integer?

I have debugging on for ognl.*, and don't see anything in catalina.out.

I'm stumped.  I don't understand why name works and rule does not.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Textfield populated from java.lang.Integer

Posted by dusty <du...@yahoo.com>.
Hey there.  You are still having issues with that form.  Maybe I can help.  I
have seen a couple different versions in your various posts, but on your
latest version you look to have it set up right.

In previous posts your action had a a ruleName and ruleDays property itself. 
In there your getter/setter signatures were different.  On your setter you
had setRuleDays(String i) and then on the getter you had Integer
getRuleDays().  In the setter you were doing the conversion from String to
Integer, but you don't need to.  OGNL/Struts will do that for you and throw
the exception you are looking for as a fieldError if you have the
conversionError interceptor.

But now the signatures look to be right, so when you say it doesn't work
what doesn't work.  Your rule bean is not populated with the rule.ruleDays
value when you post?  The value is not displayed in the field when you load
an existing rule?  The value won't persist?   

IRule is an interface?  What is the concrete implementation of the IRule you
are testing with and what does that implementation look like?  How does the
action know what IRule to create?  When you have a dynamic model and you
want to work from an interface you can use the ModelDriven interceptor to
tell the action what object to create.  


Security Management wrote:
> 
> I have the following form:
> 
> <s:form action="saveRuleName" method="POST">
> <s:textfield key="ruleName" name="rule.ruleName" required="true" />
> <s:textfield key="ruleDays" name="rule.ruleDays" required="true" size="4"
> />
> 
> 
> I have the following method in the Action class that runs before this:
> 
> public IRule getRule()
> {
>     return this.r;
> }
> 
> Now, IRule has the following:
> 
> public String getRuleName();
> public void setRuleName(String n);
> 
> public Integer getRuleDays();
> public void setRuleDays(Integer i);        
> 
> In the form, rule.ruleName works fine.  rule.ruleDays does not.  Is there
> something special to do because it's an Integer?
> 
> I have debugging on for ognl.*, and don't see anything in catalina.out.
> 
> I'm stumped.  I don't understand why name works and rule does not.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Textfield-populated-from-java.lang.Integer-tp22930807p22940683.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org