Hi Andreas,

what is the type of the model object for "flag" component? I see that inside convertInput is a ImageImpl while inside onSubmit is ImageRef
I'm experiencing the strangest behavior with a FormComponentPanel.

My custom FormComponentPanel has the following method:

     @Override
     protected void convertInput() {
         CountryImpl c = new CountryImpl(countryId,
                                         name.getConvertedInput(),
                                         currency.getConvertedInput(),
                                         flag.getConvertedInput());
         System.err.println("Setting converted input: " + c + " (identity: "
+ System.identityHashCode(c) + ")");
         setConvertedInput(c);
     }

Upon form submission I get the following printout on System.err:

Setting converted input: CountryImpl[id: 53b2c7a0986c5f4527783d16, name:
Sweden, currency: SEK, flag: ImageImpl[id=543d4328e4b0524ccbf143f8,
data.length=13452]] (identity: 1113118053)

Which is exactly what I expect. Great. Now to the part I can't explain:

In the Form that encloses this FormComponentPanel, I have the following
code:
  (
             @Override
             public void onSubmit() {
                 Country country = countryPanel.getModelObject();

                 System.err.println("country from
countryPanel.getModelObject(): " + country + " (identity: " +
System.identityHashCode(country) + ")");
                 ...
             }

And upon submit I get the following output:

country from countryPanel.getModelObject(): CountryImpl[id:
53b2c7a0986c5f4527783d16, name: Sweden, currency: SEK, flag: ImageRef[id:
543d4328e4b0524ccbf143f8]] (identity: 1025123013)

As you can see, the countryPanel.getModelObject() does not match the object
that I used in setConvertedInput! (By looking at the
System.identityHashCode one can see that they are not the same object.) Why
is this? This is how I've always done!

Other (strange) observations:

- If I change one of the text-fields (name or currency) it works as
expected! I get the same object out from getModelObject as I give to
setConvertedInput
- If I instead of countryPanel.getModelObject() do
countryPanel.getConvertedInput() I get the expected object. (In [1]
however, it says I should use getModelObject()

I've stepped through the Wicket form processing code but it's really
complex and I can't determine where it goes wrong. I have other custom
components (seemingly identical to the CountryPanel) that works as expected.

Any suggestions on what may be the issue is welcome. (I would hook you up
with a minimal test case if I could, but I can't reproduce this when
writing from scratch. Some detail seems to evade me.)

best regards,
Andreas Lundblad

[1]
https://cwiki.apache.org/confluence/display/WICKET/Creating+Custom+FormComponentPanel%27s+to+build+valid+objects+using+Wicket%27s+Form+Validation+Logic



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to