this.getForm().getModelObject() returns the model of another form page

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

this.getForm().getModelObject() returns the model of another form page

Charles Moulliard
I have created a form class which is used by a class extending
webpage. When I call the following method in the onSubmit method of
the form button I receive the model attached to another form page (=
requestFormModel) and not (= requestMessageFormModel).

Is there any restrictions/limitations using this method call :
this.getForm().getModelObject()

Here is the code of my RequestMessageForm()

public class RequestMessageForm extends Form {
       
        private static final long serialVersionUID = 1L;

    public RequestMessageForm(String name) {
   
        super(name, new CompoundPropertyModel(new RequestMessageFormModel()));

                // Add textFields
        add(textfieldRequestMessageId);
        add(textfieldFromDate);
        add(textfieldToDate);

        // Add drop down choice
        add(dropDownChoiceStatus);
        add(dropDownChoiceType);
               
                // Add buttons
                add(new Button("bSearchCriteriaRequestMessage") {
                        @Override
                        public void onSubmit() {
                                Log.info("Model received RM : " +
this.getForm().getModelObject()); // Here I receive the model
requestFormModel and not requestMessageFormModel
                                setResponsePage(new RequestMessagePage((RequestMessageFormModel)
this.getForm().getModelObject()));
                        }
                });

    }

Remark : The class RequestMessageFormModel is a simple POJO extending
the class CommonFormModel (which is also a POJO). The class
RequestFormModel used by the other page extends CommonFormModel )

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: this.getForm().getModelObject() returns the model of another form page

Johan Compagner
i dont see how that can happen if i look at your code.

is  RequestMessageForm .this != this.getForm() ??

do you nest forms?

johan


On Mon, Sep 21, 2009 at 11:38, Charles Moulliard <[hidden email]>wrote:

> I have created a form class which is used by a class extending
> webpage. When I call the following method in the onSubmit method of
> the form button I receive the model attached to another form page (=
> requestFormModel) and not (= requestMessageFormModel).
>
> Is there any restrictions/limitations using this method call :
> this.getForm().getModelObject()
>
> Here is the code of my RequestMessageForm()
>
> public class RequestMessageForm extends Form {
>
>        private static final long serialVersionUID = 1L;
>
>    public RequestMessageForm(String name) {
>
>        super(name, new CompoundPropertyModel(new
> RequestMessageFormModel()));
>
>                // Add textFields
>        add(textfieldRequestMessageId);
>        add(textfieldFromDate);
>        add(textfieldToDate);
>
>        // Add drop down choice
>        add(dropDownChoiceStatus);
>        add(dropDownChoiceType);
>
>                // Add buttons
>                add(new Button("bSearchCriteriaRequestMessage") {
>                        @Override
>                        public void onSubmit() {
>                                Log.info("Model received RM : " +
> this.getForm().getModelObject()); // Here I receive the model
> requestFormModel and not requestMessageFormModel
>                                setResponsePage(new
> RequestMessagePage((RequestMessageFormModel)
> this.getForm().getModelObject()));
>                        }
>                });
>
>    }
>
> Remark : The class RequestMessageFormModel is a simple POJO extending
> the class CommonFormModel (which is also a POJO). The class
> RequestFormModel used by the other page extends CommonFormModel )
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>