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

Reply via email to