To work around this we looked at using Metawidget's COMPONENT_ATTRIBUTE_NOT_RECREATABLE to preserve the selectedIndex at the expense of some dynamicism. We further looked at using JSF's binding attribute to try and claw back some of that dynamicism.
However, a different approach entirely would be to stop PanelTabSet storing selectedIndex internally! It turns out ICEfaces provides an API for this. The only question is where else to store selectedIndex, but keeping it inside the current request seems to work nicely. So:
- Forget all about COMPONENT_ATTRIBUTE_NOT_RECREATABLE and the binding attribute (and related mMetawidget inside the managed bean)
- Change the line in the IceFacesTabsWidgetBuilder that says...panelTabSet.getAttributes().put( UIMetawidget.COMPONENT_ATTRIBUTE_NOT_RECREATABLE, true );
...to say...panelTabSet.setValueExpression( "selectedIndex", expressionFactory.createValueExpression( elContext, "#{param['tab-" + attributes.get( NAME ) + "']}", Object.class ) );
Hope that helps!
4 comments:
You are simply great Richard!
I'll try also this solution as soon as possible!
I'm quite new to the world of Iceface and JSF and these "tricks" I'm learning from you are very useful!
Thanks a lot!
NB: I've added the ability to add and remove tabs dynamically and keeping the inner object class on the fly. If you think it could be useful I could post it. Here or on the other forum?
Bye
Simone,
Ideally you would blog it on your own blog (or, if necessary, start a blog). I'm always grateful for external blogs as a way to promote Metawidget for me.
But yes, I would be very interested in seeing what you have added.
Regards,
Richard.
Hi Richard,
Is it possible to change the metagwidget layout dynamically? Such as, switching icefaces PanelTablayout to section or reversely?
Thanks,
Leon
Leon,
Yes. I have blogged an answer here:
http://kennardconsulting.blogspot.com/2011/01/metawidget-dynamic-layout.html
Hope that helps,
Richard.
Post a Comment