Author: a.izobov
Date: 2007-06-15 11:14:32 -0400 (Fri, 15 Jun 2007)
New Revision: 1202
Modified:
trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBarItem.java
trunk/richfaces/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-20 fixed
Modified: trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
===================================================================
--- trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-06-15 13:27:33
UTC (rev 1201)
+++ trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-06-15 15:14:32
UTC (rev 1202)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
-<!--
+<!--
<!DOCTYPE components PUBLIC "-//EXADEL//Generator config/EN"
"http://exadel.com/dtds/component-config.dtd" >
-->
<components>
@@ -33,23 +33,23 @@
<name>converterMessage</name>
<classname>java.lang.String</classname>
<description>
- A ValueExpression enabled attribute that, if present, will be used as the text of the
converter message, replacing any message that comes from the converter
+ A ValueExpression enabled attribute that, if present, will be used as the text of the
converter message, replacing any message that comes from the converter.
</description>
</property>
<property>
<name>requiredMessage</name>
<classname>java.lang.String</classname>
<description>
- A ValueExpression enabled attribute that, if present, will be used as the text of the
validation message for the "required" facility, if the "required"
facility is used
+ A ValueExpression enabled attribute that, if present, will be used as the text of the
validation message for the "required" facility, if the "required"
facility is used.
</description>
</property>
<property>
<name>validatorMessage</name>
<classname>java.lang.String</classname>
<description>
- A ValueExpression enabled attribute that, if present, will be used as the text of
the validator message, replacing any message that comes from the validator
+ A ValueExpression enabled attribute that, if present, will be used as the text of
the validator message, replacing any message that comes from the validator.
</description>
- </property>
+ </property>
<property>
<name>width</name>
<classname>java.lang.String</classname>
@@ -74,7 +74,7 @@
<property>
<name>styleClass</name>
<classname>java.lang.String</classname>
- <description>Corresponds to the HTML class attribute</description>
+ <description>Corresponds to the HTML class attribute.</description>
</property>
<property>
<name>headerStyleActive</name>
@@ -96,9 +96,9 @@
<name>converter</name>
<classname>javax.faces.convert.Converter</classname>
<description>
- Id of Converter to be used or reference to a Converter
+ Id of Converter to be used or reference to a Converter.
</description>
- </property>
+ </property>
<property hidden="true">
<name>localValueSet</name>
<classname>boolean</classname>
@@ -112,7 +112,12 @@
<classname>java.lang.String</classname>
<description>JavaScript code for call before header
onclick</description>
</property>
-
+ <property>
+ <name>selectedPanel</name>
+ <classname>java.lang.Object</classname>
+ <description>Attribure defines name of selected item</description>
+ </property>
+
&ui_component_attributes;
&header_component_attributes;
&content_component_attributes;
@@ -144,7 +149,7 @@
<superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
<description>A child component of a slide panel component</description>
</tag>
-
+
<property>
<name>label</name>
<classname>java.lang.String</classname>
@@ -162,8 +167,14 @@
<classname>java.lang.String</classname>
<description>The component header style class
active</description>
</property>
-
- &ui_component_attributes;
+ <property>
+ <name>name</name>
+ <classname>java.lang.Object</classname>
+ <description>Attribute defines item name</description>
+ <defaultvalue>getId()</defaultvalue>
+ </property>
+
+ &ui_component_attributes;
&header_component_attributes;
&content_component_attributes;
<property hidden="true">
Modified: trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java
===================================================================
---
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java 2007-06-15
13:27:33 UTC (rev 1201)
+++
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java 2007-06-15
15:14:32 UTC (rev 1202)
@@ -21,8 +21,18 @@
package org.richfaces.component;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import org.richfaces.event.SwitchablePanelSwitchEvent;
+
/**
* JSF component class
*
@@ -41,6 +51,10 @@
public abstract String getWidth();
public abstract void setWidth(String width);
+
+ public abstract Object getSelectedPanel();
+
+ public abstract void setSelectedPanel(Object item);
public boolean getRendersChildren() {
return true;
@@ -49,5 +63,46 @@
return CLIENT_METHOD;
}
+ public void broadcast(FacesEvent facesEvent) throws AbortProcessingException {
+ if (facesEvent instanceof SwitchablePanelSwitchEvent) {
+ if (isRendered()) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ Object oldValue = getValue();
+ super.broadcast(facesEvent);
+ SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent)
facesEvent;
+ Object newValue = convertSwitchValue(switchEvent.getEventSource(),
+ switchEvent.getValue());
+ if (oldValue == null && newValue != null ||
+ oldValue != null && !oldValue.equals(newValue)) {
+ Object newName = null;
+ List items = getChildren();
+ for(Iterator it = items.iterator();it.hasNext();) {
+ UIComponent comp = (UIComponent)it.next();
+ if (comp instanceof UIPanelBarItem) {
+ UIPanelBarItem item = (UIPanelBarItem) comp;
+ if (item.getClientId(facesContext).equals(newValue)) {
+ newName = item.getName();
+ break;
+ }
+ }
+ }
+
+ if (newName != null) {
+ ValueBinding valueBinding =
getValueBinding("selectedPanel");
+ if (valueBinding != null) {
+ valueBinding.setValue(facesContext, newName);
+ setSelectedPanel(null);
+ } else {
+ setSelectedPanel(newName);
+ }
+ }
+ }
+ }
+ } else {
+ super.broadcast(facesEvent);
+ }
+ }
+
}
Modified:
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBarItem.java
===================================================================
---
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBarItem.java 2007-06-15
13:27:33 UTC (rev 1201)
+++
trunk/richfaces/panelbar/src/main/java/org/richfaces/component/UIPanelBarItem.java 2007-06-15
15:14:32 UTC (rev 1202)
@@ -32,7 +32,11 @@
public abstract void setLabel(String label);
- public UIPanelBar getPanel(){
+ public abstract Object getName();
+
+ public abstract void setName(Object name);
+
+ public UIPanelBar getPanel(){
//XXX by nick - andrew - panelBarItem is an immediate panelBar child, no need to
traverse up a lot
return (UIPanelBar) getParent();
}
Modified:
trunk/richfaces/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
===================================================================
---
trunk/richfaces/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-06-15
13:27:33 UTC (rev 1201)
+++
trunk/richfaces/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-06-15
15:14:32 UTC (rev 1202)
@@ -28,6 +28,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import org.ajax4jsf.framework.ajax.AjaxScript;
import org.ajax4jsf.framework.ajax.ImageCacheScript;
@@ -37,8 +38,11 @@
import org.ajax4jsf.framework.resource.InternetResource;
import org.ajax4jsf.framework.resource.PrototypeScript;
import org.richfaces.component.UIPanelBar;
+import org.richfaces.component.UIPanelBarItem;
import org.richfaces.event.SwitchablePanelSwitchEvent;
+import com.sun.org.apache.bcel.internal.generic.INSTANCEOF;
+
public abstract class PanelBarRendererBase extends HeaderResourcesRendererBase {
public static final String PANEL_BAR_RESOURCES = "PANEL_BAR_RESOURCES";
@@ -61,20 +65,29 @@
public String expanded(FacesContext context, UIComponent component) throws IOException
{
UIPanelBar panelbar = (UIPanelBar) component;
String value = (String)panelbar.getValue();
- if (value != null) {
+ ValueBinding valueBinding = panelbar.getValueBinding("selectedPanel");
+ if (value != null && valueBinding == null) {
UIComponent item = component.findComponent(value);
if (item != null) {
panelbar.setValue(item.getClientId(context));
return item.getClientId(context);
}
- }
+ } else {
+ Object selected = panelbar.getSelectedPanel();
+ if (selected != null) {
+ List items = panelbar.getChildren();
+ for(Iterator it = items.iterator();it.hasNext();) {
+ UIComponent comp = (UIComponent)it.next();
+ if (comp instanceof UIPanelBarItem) {
+ UIPanelBarItem item = (UIPanelBarItem) comp;
+ if (item.getName().equals(selected)) {
+ return item.getClientId(context);
+ }
+ }
+ }
+ }
+ }
return "";
-/* Object expanded=component.getAttributes().get(EXPANDED_ATTR);
- String exp=component.getChildCount()==0?"-1":"0";
- if (expanded!=null) {
- exp=expanded.toString();
- }
- return exp; */
}
public String width(FacesContext context, UIComponent component) throws IOException {