so you are saying that this little piece of code:

TextField tf = new TextField(qid + "Cat", new PropertyModel(pojoObj, "text"));
boolean test = pojoObject.getText().equals(tf.getModelObject());

then test is false?



On 10/28/05, Chantal Ackermann <[EMAIL PROTECTED]> wrote:
Hello all, hello Igor,

thanks for your helpful reply.

I adjusted the code so that only the return of
TextField.getModelObjectAsString is set in the approriate POJO, which
is then written to the database, and the ComboBox gets updated. The
backend routines are all called as expected.

but...

I still do not get a value from the TextField. I tried PropertyModel
and Model and both have a null ModelObject and thus return an empty
string on getModelObjectAsString().

Here is my logging output with Model:

INFO  - NaviPage                   -
NewCategoryButton.onSubmit():semNaviButton
INFO  - NaviPage                   - TextField Model:
Model:classname=[wicket.model.Model]:nestedModel=[null]:object=[null]
INFO  - NaviPage                   - TextField ModelObject: null
INFO  - NaviPage                   - TextField ModelObjectString:

with PropertyModel:

INFO  - NaviPage                   -
NewCategoryButton.onSubmit():semNaviButton
INFO  - NaviPage                   - TextField Model:
Model:classname=[wicket.model.PropertyModel]:attached=false:
nestedModel=[null]:_expression_=[text]:propertyType=[null]
INFO  - NaviPage                   - TextField ModelObject: null
INFO  - NaviPage                   - TextField ModelObjectString:


Instantiation of the TextField with Model:

TextField tf = new TextField(qid + "Cat", new Model());

with PropertyModel:

TextField tf = new TextField(qid + "Cat", new PropertyModel(pojoObj,
"text"));

The onSubmit Method of the Button Subtype:

                public void onSubmit()
                {
                        log.info("NewCategoryButton.onSubmit():" + getId());
                        IModel m = textField.getModel();
                        log.info("TextField Model: " + m);
                        log.info("TextField ModelObject: " + textField.getModelObject());
                        log.info("TextField ModelObjectString: " +
textField.getModelObjectAsString());
                        ids.setText(textField.getModelObjectAsString());
                        getDao().merge(ids);
                        choice.setChoices (getDao().findAllFromClass(ids.getClass()));
                        choice.updateModel();
                }

I did realize though, that the nested Model was the wrong way to go.
But why is the Model Object null? IMHO this one is the object that is
used to return the String value from, inside getModelObjectAsString. Do
I have to set it myself? (I thought at least PropertyModel would use my
POJO?) I can't find a hint in the API.

I am quite sure that I missed something crucially substantial about
Models... ^^

Best regards,
Chantal

> From: "Igor Vaynberg" <[EMAIL PROTECTED]>
> To: < wicket-user@lists.sourceforge.net>
> Subject: RE: [Wicket-user] Accessing the PropertyModel of a TextField
> (former How can a model wrap more than one POJO)
> Date: Wed, 26 Oct 2005 09:36:57 -0700
> Reply-To: wicket-user@lists.sourceforge.net
>
> The nested model does not refer to your object, it refers to a model
> nested
> inside the current model (notice the Imodel return type). Some models
> support this, others don't. The property model does not. It has its own
> internal pointer to your object. To get the text from the textfield
> simply
> do: textfield.getModelObjectAsString() - this does the following -
> retrieve
> the model from the textfield which is your property model, calls
> getModelObject on the property model which retrieves the property from
> your
> model object, and then casts that to a string all in one convinient
> step.
>
> -Igor
>



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to