You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Victor Neo <ic...@gmail.com> on 2007/06/21 10:44:51 UTC

[S2] Unable to access Model properties when using ModelDriven

I have an Action class that implements ModelDriven.

My DummyForm object will be used to store the user's input (just a userName
attribute in this case).


ValidateDummy ActionClass:
public class ValidateDummy implements ModelDriven{

    private DummyForm form;

    public String execute(){
        return INPUT;
    }

    public Object getModel(){
        if(form == null) 
            return new DummyForm();

        return form;
    }
} 


DummyForm:
public class DummyForm{
    private String userName;
    // getters and setters for userName..
}


dummyvalidate.jsp: (irrelevant parts removed)
<s:form method="post">
    <s:textfield name="userName" label="Enter User Name"/>
    <s:submit/>
</s:form>


After the user enters a user name and submits, the userName attribute inside
the form should be populated with the user's input, right? However, userName
remained null.

I have added a interceptor-ref to "model-driven" as well.

Am I missing any requirements here?
-- 
View this message in context: http://www.nabble.com/-S2--Unable-to-access-Model-properties-when-using-ModelDriven-tf3957353.html#a11228982
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


Re: [S2] Unable to access Model properties when using ModelDriven

Posted by Don Brown <do...@gmail.com>.
The problem could be the order of the interceptors.  Take a look at
the showcase application as it has at least one model-driven example
action.

Don

On 6/21/07, Victor Neo <ic...@gmail.com> wrote:
>
> I have an Action class that implements ModelDriven.
>
> My DummyForm object will be used to store the user's input (just a userName
> attribute in this case).
>
>
> ValidateDummy ActionClass:
> public class ValidateDummy implements ModelDriven{
>
>     private DummyForm form;
>
>     public String execute(){
>         return INPUT;
>     }
>
>     public Object getModel(){
>         if(form == null)
>             return new DummyForm();
>
>         return form;
>     }
> }
>
>
> DummyForm:
> public class DummyForm{
>     private String userName;
>     // getters and setters for userName..
> }
>
>
> dummyvalidate.jsp: (irrelevant parts removed)
> <s:form method="post">
>     <s:textfield name="userName" label="Enter User Name"/>
>     <s:submit/>
> </s:form>
>
>
> After the user enters a user name and submits, the userName attribute inside
> the form should be populated with the user's input, right? However, userName
> remained null.
>
> I have added a interceptor-ref to "model-driven" as well.
>
> Am I missing any requirements here?
> --
> View this message in context: http://www.nabble.com/-S2--Unable-to-access-Model-properties-when-using-ModelDriven-tf3957353.html#a11228982
> 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
>
>

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