yeah, that's the pattern to use. i think it's not that inelegant. getObject() should be transparent and cause the attach to happen. that's just part of how detachable models should work.
btw, i'm doing a really serious refactor of choice models and it's getting really elegant at last.
the changes should not break much code except any code working with IDetachableChoiceModel, which has gone away. the changes have greatly reduced the size and complexity of not only choice component implementations, but also of detachable choice models as well.
once i test a bit i'll check in.
the other change i want to do is to make RadioChoice work exactly like the other choice subclasses. this /will/ break people and i'm sorry. but i think it will be worth it because, in the end, you will be able to switch between dropdowns, lists and radio buttons with hardly any change to your code.
jon
Eelco Hillenius wrote:
This is the problem... look at the failing test:
label3.add(new AttributeModifier("class", true, new DetachableModel()
{
private String text = null;
public void onDetach() { System.out.println("AttributeModifier model detached"); text = null; }
public void onAttach() { System.out.println("AttributeModifier model attached"); text = "insertLabel"; }
public Object getObject() { return text; }
public void setObject(Object object) { text = object.toString(); } }));
Since attach is now only called from getObject directly, in the above case, the model is never attached, as getObject is overriden. So, changing that to:
public Object getObject() { attach(); return text; }
works.
Though it might not win the beauty contest, I think it is a good idea to both call attach on Component.getModel() and on IModel.getObject(), the latter being usefull for when using models before (or without) actually putting them on a component.
Eelco
Jonathan Locke wrote:
yeah, i saw this. i know i made a bunch of changes, but i just could not figure out how this NPE would have anything to do with the code i touched...
ideas anyone?
Juergen Donnerstag wrote:
On my machine the junit test AttributeModifierComponentTest currently fails. Any idea?
Juergen
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
