You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Martin Ahrer <ma...@gmx.at> on 2007/06/13 13:08:11 UTC
Re: [Trinidad] panelTabbed style
Meanwhile I have found a good workaround that I wanted to share...
I'm using a navigationPane component bound to a custom class for controlling
the active tab. The only problem that I still face is to make the first tab
active when the navigationPane is displayed the first time? Maybe someone
reading this might have an idea?
<tr:navigationPane hint="tabs"
binding="#{customerNavigationPaneController.navigationPane}">
<tr:commandNavigationItem id="customer"
text="#{resources['customer.label']}" accessKey="A"
actionListener="#{customerNavigationPaneController.navigationItemAction}"
/>
<tr:commandNavigationItem id="address"
text="#{resources['customer.address.label']}"
icon="/images/16x16/apps/internet-mail.png"
actionListener="#{customerNavigationPaneController.navigationItemAction}"
/>
<tr:commandNavigationItem id="billingAddress"
text="#{resources['customer.billingAddress.label']}"
icon="/images/16x16/apps/internet-mail.png"
actionListener="#{customerNavigationPaneController.navigationItemAction}"
/>
</tr:navigationPane>
<tr:panelBox>
<tr:panelFormLayout labelWidth="100"
rendered="#{customerNavigationPaneController.selectedItem=='customer'}">
...
</tr:panelFormLayout>
<tr:panelFormLayout labelWidth="100"
rendered="#{customerNavigationPaneController.selectedItem=='address'}">
...
</tr:panelFormLayout>
<tr:panelFormLayout labelWidth="100"
rendered="#{customerNavigationPaneController.selectedItem=='billingAddress'}">
...
</tr:panelFormLayout>
/*
* Copyright 2002-2007 Martin Ahrer.
*
* $Id$
*/
package traveller.view.trinidad;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.UIXCommand;
import org.apache.myfaces.trinidad.context.RequestContext;
/**
* @author Martin Ahrer
*
*/
public class NavigationPaneController {
private String defaultItemId;
private UIComponent navigationPane;
public UIComponent getNavigationPane() {
return navigationPane;
}
public void setNavigationPane(UIComponent navigationPane) {
this.navigationPane = navigationPane;
// if (!navigationPane.getChildren().isEmpty() && getSelectedItem() ==
null) {
// setSelectedItem((UIComponent) navigationPane.getChildren().get(0));
// }
}
public void navigationItemAction(ActionEvent event) {
setSelectedItem(event.getComponent());
RequestContext adfContext = RequestContext.getCurrentInstance();
adfContext.addPartialTarget(getNavigationPane());
}
protected void setSelectedItem(UIComponent actionItem) {
List children = getNavigationPane().getChildren();
for (UIXCommand child : children) {
FacesBean childFacesBean = child.getFacesBean();
PropertyKey selectedKey = childFacesBean.getType().findKey("selected");
if (selectedKey != null) {
childFacesBean.setProperty(selectedKey, (child == actionItem));
}
}
}
public String getSelectedItem() {
List children = getNavigationPane().getChildren();
for (UIXCommand child : children) {
FacesBean childFacesBean = child.getFacesBean();
PropertyKey selectedKey = childFacesBean.getType().findKey("selected");
if (selectedKey != null) {
if (!(null == childFacesBean.getProperty(selectedKey))
&& ((Boolean) childFacesBean.getProperty(selectedKey))) {
return child.getId();
}
}
}
// UIComponent defaultItem =
getNavigationPane().findComponent(getDefaultItemId());
// if (defaultItem != null) {
// setSelectedItem(defaultItem);
// }
return getDefaultItemId();
}
public String getDefaultItemId() {
return defaultItemId;
}
public void setDefaultItemId(String defaultItem) {
this.defaultItemId = defaultItem;
}
}
Martin Ahrer wrote:
>
> the panelTabbed only creates very basic styled links for switching between
> tabs. How can I get really nice tabs like panelPage creates them for the
> navigation tabs. Is this work in progress? I had initially used ADF Faces
> which nicely presented tabs! Is it a matter of customizing some CSS or is
> this work in progress?
>
--
View this message in context: http://www.nabble.com/-Trinidad--panelTabbed-style-tf3856602.html#a11097120
Sent from the MyFaces - Users mailing list archive at Nabble.com.