- The ICEfaces PanelTabSet doesn't have an option to switch tabs on the client-side, using just JavaScript and CSS to show/hide the tabs (RichFaces has switchType="client")
- The ICEfaces PanelTabSet stores its tab state inside the component, so when doing server-side switching you cannot destroy and recreate the component or the tabs won't switch
There are a few answers to this question:
- There is still quite a lot of dynamicism, even with COMPONENT_ATTRIBUTE_NOT_RECREATABLE set. Metawidget is smart enough to work around the COMPONENT_ATTRIBUTE_NOT_RECREATABLE components, and still recreates their siblings and even their children. As the project from the previous post shows, you can have an 'Edit' button that makes the components (both inside and outside the tab) turn from read-only labels into input boxes
- The COMPONENT_ATTRIBUTE_NOT_RECREATABLE only applies during POST requests. Re-rendering the page afresh as a GET request works fine. So if your user clicks a link to navigate into the page with the TabPanelSet on it, no problem
I have put together a complete project you can download from here. It'll produce something that looks like this:
The trick is to use JSF's binding attribute. As I blogged previously, this is a little-used but very useful feature of JSF that allows programmatic control over your components. So in your page you do:
<m:metawidget value="#{headerDemo}" binding="#{headerDemo.metawidget}"/>
And in your managed bean you do:
public UIMetawidget getMetawidget() {
return mMetawidget;
}
public void setMetawidget( UIMetawidget metawidget ) {
mMetawidget = metawidget;
}
@UiAction
@UiComesAfter( "details" )
public void addTab() {
mDetails.add( new Detail( mDetails.size(), "Detail #" + mDetails.size() ) );
mMetawidget.getChildren().clear();
}
return mMetawidget;
}
public void setMetawidget( UIMetawidget metawidget ) {
mMetawidget = metawidget;
}
@UiAction
@UiComesAfter( "details" )
public void addTab() {
mDetails.add( new Detail( mDetails.size(), "Detail #" + mDetails.size() ) );
mMetawidget.getChildren().clear();
}
Hope that helps!
0 comments:
Post a Comment