The answer is yes! You can call...
metawidget.setLayout( myLayout );
...at any time to dynamically update the layout. The questioner was asking in relation to JSF, and the hardest bit in JSF is actually getting programmatic access to the Metawidget. This requires the binding attribute I've blogged about previously.
But once past that, you can put together something like this:
Note the buttons at the buttom that allow you to select which layout to use. I have put together the complete project you can download from here.
10 comments:
Thanks a lot, Richard. It is great!
Leon
Hi Richard,
I built an icefaces panelTabSet layout decorator, but I had to set "METAWIDGET_NOT_RECREATABLE" TO IT. Then the tabs cannot switch if I put an another layout decorator insided of it, such as outputTextLayoutDecorator. I am thinking it must be caused by "METAWIDGET_NOT_RECREATABLE" ATTRIBUTE. Is there a way to slove it?
Thanks,
Leon
Leon,
Yes, it will be caused by METAWIDGET_NOT_RECREATABLE. Try this blog entry...
http://kennardconsulting.blogspot.com/2010/11/metawidget-collections-support-part-2_25.html
...which describes how to get PanelTabSet working without METAWIDGET_NOT_RECREATABLE.
Does that work for you?
Richard.
Richard,
I tried it witg "selectedIndex", but it still did not work. The tabs cannot be switched. I guess the decorator is different from widgetbuilder, then It does not bind the "selectedIndex" with NAME correctly. How does the "selectedIndex" binding in PanelTabSet work?
Thanks,
Leon
Leon,
Could you please send as much of the code as you can to support@metawidget.org, and I'll take a look at it?
Thanks,
Richard.
Leon,
Interestingly, I just tried creating a PanelTabSetLayoutDecorator and it appears to work without either METAWIDGET_NOT_RECREATABLE or selectedIndex.
I have checked it into SVN under org.metawidget.faces.component.html.layout.icefaces.PanelTabSetLayoutDecorator
Could you please see how it differs from yours?
Regards,
Richard.
Thanks Richard,
I compared the codes, there were almost same. But it did not work without METAWIDGET_NOT_RECREATABLE.
I am using ICEFaces 2.0, maybe it cause the problem.
Regards,
Leon
Leon,
I just tried the code you sent. It appears ICEFaces 2.0 and 'selectedIndex' is fine, but the EL '#{param['tab-0']}' is read-only under JSF 2.0. Possibly because of the new EL?
Anway, #{requestScope.tab0} still works fine, so try:
"#{requestScope.tab" + attributes.get( NAME ) + "}"
Does that work for you?
Richard.
Richard,
It is great. This way work well!
Thanks,
Leon
Leon,
Just to let you know this work as now been released as part of Metawidget v1.10. I'd be most grateful if you could download it and confirm it works for you.
Regards,
Richard.
Post a Comment