that looks much much better.

you can still get rid of those two models for the dropdownlist with:
       private AddressEntry quickAddress;
       Private List<AddressEntry> quickAddresses=new
ArrayList<AddressEntry>();

and then

add(new DropDownChoice("id", new PropertyModel(this, "quickAddress"), new
PropertyModel(this, "quickAddresses"),...)

that way you never actually have to reference model objects directly, your
code that deals with these addresses then simply works with those two
fields. it keeps wicket out of the way.

eg

private void performLookup(boolean showAllPremises) {
...                List<AddressEntry> entries = AddressUtil.getAddresses(
                       getAddress().getPostcode(), showAllPremises);
               addressListModel.setObject(null, entries);

becomes
quickAddresses=AddressUtil.getAddresses(getAddress().getPostcode(),
showAllPremises);

much simpler/cleaner imho

-igor


On 5/3/07, John RDF <[EMAIL PROTECTED]> wrote:


The drop down list does not directly relate to the form model (as the
visible
value is a user readable summary not the data structure I need) and so I
need to keep a reference to something even if its a model or two. Take a
look at this version which still works with same quirks.. Any better?

http://www.nabble.com/file/8198/AddressPanel.java AddressPanel.java

John


Eelco Hillenius wrote:
>
> One thing that I'm wondering is why you declare your components as
> member variables. It's not really wrong, but it's more code without
> any advantage, and potentially scope creep (in that you might be
> tempted to use the components directly rather then to work through
> models.
>
> Eelco
>
> On 5/3/07, John RDF <[EMAIL PROTECTED]> wrote:
>>
>> Thanks Igor and I am curious. Why is it nasty in your opinion? Which
>> parts? I
>> am open to trying other ways that I am not aware of. This is not how I
>> originally wanted to implement it but I have tried many ways so far
>> (different models on different components in the hierarchy,
>> nesting/inheriting models etc) and this is the closest to working so
far.
>> Other ways I tried which seemed more elegant had more serious problems
in
>> practice especially when compounding and nesting panels more times
which
>> I
>> need.
>>
>> John
>>
>>
>> igor.vaynberg wrote:
>> >
>> > although that is some nasty code wrt to wicket, i dont see why
anything
>> > would go wrong. try and replicate it in a quickstart and someone will
>> go
>> > through it.
>> >
>> > -igor
>> >
>> >
>> > On 5/2/07, John RDF <[EMAIL PROTECTED]> wrote:
>> >>
>> >> I am still having real trouble making truly reusable panels for
domain
>> >> objects that work consistently without quirky behaviour. I attach my
>> code
>> >> for an address panel. It contains a form as it has buttons for
looking
>> up
>> >> streets from the postcode. This panel needs to be embedded with
>> multiple
>> >> instances in same page and/or other forms and panels. The lookup etc
>> >> works
>> >> except it has some strange side effects. When I first enter a
postcode
>> >> and
>> >> press the lookup button, all the other postcode fields are populated
>> >> further
>> >> down the page. Then when I select an address from the now populated
>> drop
>> >> down list, and then press use selected button, all the remaining
>> fields
>> >> of
>> >> all other address forms also get populated! This weird behaviour
only
>> >> occurs
>> >> in a downwards direction thoughout the page and only when the user
has
>> >> not
>> >> already entered something in a field. Can people please look at the
>> code
>> >> below. I cannot see why it should behave this way.
>> >> AddressPanel.java<http://www.nabble.com/file/8180/AddressPanel.java>
>> >> AddressPanel.html <http://www.nabble.com/file/8181/AddressPanel.html
>
>> >> AddressDO.java <http://www.nabble.com/file/8182/AddressDO.java> The
>> form
>> >> that adds these panels does it as below add(new
>> >> AddressPanel("proposedAddress",
>> >> getCreditCheckDTO().getProposedAddress()));
>> >> add(new AddressPanel("currentAddress",
>> >> getCreditCheckDTO().getCurrentAddress())); add(new
>> >> AddressPanel("previousAddress",
>> >> getCreditCheckDTO().getPreviousAddress()));
>> >> The form has a compound property model has a pojo for its model
>> object.
>> >> This
>> >> is returned by getCreditCheckDTO(). Thanks in advance, John
>> >> ------------------------------
>> >> View this message in context: Reusable Panels/Nested Forms/Models
and
>> >> weird
>> >>
>> behaviour<
http://www.nabble.com/Reusable-Panels-Nested-Forms-Models-and-weird-behaviour-tf3680964.html#a10287153
>
>> >> Sent from the Wicket - User mailing list
>> >> archive<http://www.nabble.com/Wicket---User-f13976.html>at
>> >> Nabble.com.
>> >>
>> >>
>>
-------------------------------------------------------------------------
>> >> This SF.net email is sponsored by DB2 Express
>> >> Download DB2 Express C - the FREE version of DB2 express and take
>> >> control of your XML. No limits. Just data. Click to get it now.
>> >> http://sourceforge.net/powerbar/db2/
>> >> _______________________________________________
>> >> Wicket-user mailing list
>> >> Wicket-user@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >>
>> >>
>> >
>> >
>>
-------------------------------------------------------------------------
>> > This SF.net email is sponsored by DB2 Express
>> > Download DB2 Express C - the FREE version of DB2 express and take
>> > control of your XML. No limits. Just data. Click to get it now.
>> > http://sourceforge.net/powerbar/db2/
>> > _______________________________________________
>> > Wicket-user mailing list
>> > Wicket-user@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >
>> >
>>
>> --
>> View this message in context:
>>
http://www.nabble.com/Reusable-Panels-Nested-Forms-Models-and-weird-behaviour-tf3680964.html#a10301142
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>>
-------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

--
View this message in context:
http://www.nabble.com/Reusable-Panels-Nested-Forms-Models-and-weird-behaviour-tf3680964.html#a10302391
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to