Author: Alex.Kolonitsky
Date: 2010-09-01 04:33:51 -0400 (Wed, 01 Sep 2010)
New Revision: 19058
Modified:
trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
Log:
Toggle Panel bug fixing and refactoring
add header facet as default for headerActive/Inactive/Disabled in Accordion
id as default for name in togglePanelItem
Modified: trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-01
08:15:07 UTC (rev 19057)
+++ trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-01
08:33:51 UTC (rev 19058)
@@ -26,17 +26,17 @@
<pn:accordionItem header="label 1">
<f:facet name="headerInactive">headerInactive
1</f:facet>
<f:facet name="headerActive">headerActive
1</f:facet>
- <f:facet name="headerDisable">headerDisable
1</f:facet>
+ <f:facet name="header">headerDisable
1</f:facet>
content 1
</pn:accordionItem>
<pn:accordionItem header="label 2"
disabled="true">
<f:facet name="headerInactive">headerInactive
2</f:facet>
- <f:facet name="headerActive">headerActive
2</f:facet>
+ <f:facet name="header">headerActive
2</f:facet>
<f:facet name="headerDisable">headerDisable
2</f:facet>
content 2
</pn:accordionItem>
<pn:accordionItem header="label 3">
- <f:facet name="headerInactive">headerInactive
3</f:facet>
+ <f:facet name="header">headerInactive
3</f:facet>
<f:facet name="headerActive">headerActive
3</f:facet>
<f:facet name="headerDisable">headerDisable
3</f:facet>
content 3
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -37,9 +37,12 @@
public static final String COMPONENT_TYPE =
"org.richfaces.CollapsiblePanel";
public static final String COMPONENT_FAMILY =
"org.richfaces.CollapsiblePanel";
- private static final String STATE_EXPANDED = "expanded";
- private static final String STATE_COLLAPSED = "collapsed";
+ public enum States {
+ expanded,
+ collapsed
+ }
+
protected AbstractCollapsiblePanel() {
setRendererType("org.richfaces.CollapsiblePanel");
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -56,6 +56,11 @@
public static final String COMPONENT_FAMILY = "org.richfaces.TogglePanel";
+ public static final String META_NAME_FIRST = "@first";
+ public static final String META_NAME_PREV = "@prev";
+ public static final String META_NAME_NEXT = "@next";
+ public static final String META_NAME_LAST = "@last";
+
// TODO What is MessageId ?
public static final String UPDATE_MESSAGE_ID =
"javax.faces.component.UIInput.UPDATE";
@@ -467,13 +472,13 @@
}
public AbstractTogglePanelItem getItem(String name) {
- if ("(a)first".equals(name)) {
+ if (META_NAME_FIRST.equals(name)) {
return getFirstItem();
- } else if ("(a)prev".equals(name)) {
+ } else if (META_NAME_PREV.equals(name)) {
return getPrevItem();
- } else if ("(a)next".equals(name)) {
+ } else if (META_NAME_NEXT.equals(name)) {
return getNextItem();
- } else if ("(a)last".equals(name)) {
+ } else if (META_NAME_LAST.equals(name)) {
return getLastItem();
} else {
return getItemByIndex(getChildIndex(name));
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -28,6 +28,7 @@
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
import java.io.IOException;
+import java.util.Map;
/**
* @author akolonitsky
@@ -94,8 +95,9 @@
}
protected static void hidePanelItem(UIComponent item) {
- //TODO nick - attributes shouldn't be overwritten
- item.getAttributes().put(RendererUtils.HTML.STYLE_ATTRIBUTE,
"display:none");
+ Map<String,Object> attrs = item.getAttributes();
+ Object style = attrs.get(RendererUtils.HTML.STYLE_ATTRIBUTE);
+ attrs.put(RendererUtils.HTML.STYLE_ATTRIBUTE, "display:none; " +
style);
}
public abstract String getName();
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -22,6 +22,8 @@
package org.richfaces.component;
+import org.richfaces.renderkit.html.DivPanelRenderer;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
@@ -36,6 +38,12 @@
public static final String COMPONENT_FAMILY =
"org.richfaces.TogglePanelTitledItem";
+ public enum HeaderStates {
+ active,
+ inactive,
+ disable
+ }
+
protected AbstractTogglePanelTitledItem() {
setRendererType("org.richfaces.TogglePanelTitledItem");
}
@@ -71,4 +79,20 @@
encodeEnd(context);
}
+
+ public UIComponent getHeaderFacet(Enum<?> state) {
+ return getHeaderFacet(this, state);
+ }
+
+ public static UIComponent getHeaderFacet(UIComponent component, Enum<?> state)
{
+ UIComponent headerFacet = null;
+ if (state != null) {
+ headerFacet = component.getFacet("header" +
DivPanelRenderer.capitalize(state.toString()));
+ }
+
+ if (headerFacet == null) {
+ headerFacet = component.getFacet("header");
+ }
+ return headerFacet;
+ }
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -36,7 +36,7 @@
}
public String getName() {
- return (String) getStateHelper().eval(PropertyKeys.name);
+ return (String) getStateHelper().eval(PropertyKeys.name, getId());
}
public void setName(String name) {
@@ -50,6 +50,4 @@
public void setSwitchType(SwitchType switchType) {
getStateHelper().put(PropertyKeys.switchType, switchType);
}
-
-
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -54,7 +54,7 @@
}
public String getTargetItem() {
- return (String) getStateHelper().eval(PropertyKeys.targetItem);
+ return (String) getStateHelper().eval(PropertyKeys.targetItem,
AbstractTogglePanel.META_NAME_NEXT);
}
public void setTargetItem(String target) {
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -51,7 +51,7 @@
super(methodExprOneArg, methodExprZeroArg);
}
- // ------------------------------------------------------- Event Method
+ // ------------------------------------------------------- Listener Method
public void processChangeExpand(ChangeExpandEvent changeExpandEvent) throws
AbortProcessingException {
processEvent(changeExpandEvent);
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -22,13 +22,7 @@
package org.richfaces.event;
-import javax.el.ELContext;
-import javax.el.ELException;
import javax.el.MethodExpression;
-import javax.el.MethodNotFoundException;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
/**
@@ -44,158 +38,23 @@
* @since -4712-01-01
*
*/
-//TODO nick - good candidate for utility class
-public class MethodExpressionItemChangeListener implements ItemChangeListener,
StateHolder {
+public class MethodExpressionItemChangeListener extends MethodExpressionEventListener
implements ItemChangeListener {
- private static final Class<?>[] ITEM_CHANGE_LISTENER_ZERO_ARG_SIG = new Class[]
{};
-
- private static final Object[] NO_PARAMS = new Object[0];
-
- // ------------------------------------------------------ Instance Variables
-
- private MethodExpression methodExpressionOneArg = null;
- private MethodExpression methodExpressionZeroArg = null;
-
- private boolean isTransient;
-
public MethodExpressionItemChangeListener() {
}
- /**
- * <p><span class="changed_modified_2_0">Construct</span>
a {@link
- * ItemChangeListener} that contains a {@link
- * MethodExpression}.<span
- * class="changed_added_2_0">To accomodate method expression targets
- * that take no arguments instead of taking a {@link
- * ItemChangeEvent} argument</span>, the implementation of this
- * class must take the argument <code>methodExpressionOneArg</code>,
- * extract its expression string, and create another
- * <code>MethodExpression</code> whose expected param types match
- * those of a zero argument method. The usage requirements for both
- * of these <code>MethodExpression</code> instances are described in
- * {@link #processItemChange}.</p>
- *
- * @param methodExpressionOneArg a <code>MethodExpression</code>
- * that points to a method that returns <code>void</code> and takes
- * a single argument of type {@link ItemChangeEvent}.
- */
- public MethodExpressionItemChangeListener(MethodExpression methodExpressionOneArg) {
-
- super();
- this.methodExpressionOneArg = methodExpressionOneArg;
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- this.methodExpressionZeroArg = context.getApplication().
- getExpressionFactory().createMethodExpression(elContext,
- methodExpressionOneArg.getExpressionString(), Void.class,
- ITEM_CHANGE_LISTENER_ZERO_ARG_SIG);
+ public MethodExpressionItemChangeListener(MethodExpression methodExprOneArg) {
+ super(methodExprOneArg);
}
- /**
- * <p>Construct a {@link ItemChangeListener} that contains a {@link
MethodExpression}.</p>
- *
- * @param methodExpressionOneArg
- * @param methodExpressionZeroArg
- */
- public MethodExpressionItemChangeListener(MethodExpression methodExpressionOneArg,
- MethodExpression methodExpressionZeroArg) {
-
- super();
- this.methodExpressionOneArg = methodExpressionOneArg;
- this.methodExpressionZeroArg = methodExpressionZeroArg;
+ public MethodExpressionItemChangeListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
}
- // ------------------------------------------------------- Event Method
+ // ------------------------------------------------------- Listener Method
- /**
- * <p><span class="changed_modified_2_0">Call</span>
through to the
- * {@link MethodExpression} passed in our constructor. <span
- * class="changed_added_2_0">First, try to invoke the
- * <code>MethodExpression</code> passed to the constructor of this
- * instance, passing the argument {@link ItemChangeEvent} as the
- * argument. If a {@link MethodNotFoundException} is thrown, call
- * to the zero argument <code>MethodExpression</code> derived from
- * the <code>MethodExpression</code> passed to the constructor of
- * this instance. If that fails for any reason, throw an {@link
- * AbortProcessingException}, including the cause of the
- * failure.</span></p>
- *
- * @throws NullPointerException {@inheritDoc}
- * @throws AbortProcessingException {@inheritDoc}
- */
public void processItemChange(ItemChangeEvent itemChangeEvent) throws
AbortProcessingException {
-
- if (itemChangeEvent == null) {
- throw new NullPointerException();
- }
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- // PENDING: The corresponding code in MethodExpressionActionListener
- // has an elaborate message capture, logging, and rethrowing block.
- // Why not here?
- try {
- methodExpressionOneArg.invoke(elContext, new Object[] {itemChangeEvent});
- } catch (MethodNotFoundException mnf) {
- if (null != methodExpressionZeroArg) {
-
- try {
- // try to invoke a no-arg version
- methodExpressionZeroArg.invoke(elContext, NO_PARAMS);
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
- }
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
+ processEvent(itemChangeEvent);
}
-
-
- // ------------------------------------------------ Methods from StateHolder
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be saved.</p>
- */
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- return new Object[] {
- UIComponentBase.saveAttachedState(context, methodExpressionOneArg),
- UIComponentBase.saveAttachedState(context, methodExpressionZeroArg)
- };
- }
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be restored.</p>
- */
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (state == null) {
- return;
- }
-
- methodExpressionOneArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[0]);
- methodExpressionZeroArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[1]);
- }
-
-
- public boolean isTransient() {
- return isTransient;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -34,6 +34,8 @@
import javax.faces.context.ResponseWriter;
import java.io.IOException;
+import static org.richfaces.component.AbstractTogglePanelTitledItem.HeaderStates;
+
/**
*
* <div id="clientId" class="rf-aci">
@@ -50,7 +52,7 @@
* @author akolonitsky
* @since 2010-08-05
*/
-@ResourceDependencies({ // TODO review
+@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
@@ -118,15 +120,15 @@
AbstractTogglePanelTitledItem titledItem = (AbstractTogglePanelTitledItem)
component;
boolean isActive = titledItem.isActive();
boolean isDisabled = titledItem.isDisabled();
- encodeHeader(facesContext, component, responseWriter, "inactive",
!isActive && !isDisabled);
- encodeHeader(facesContext, component, responseWriter, "active",
isActive && !isDisabled);
- encodeHeader(facesContext, component, responseWriter, "disable",
isDisabled);
+ encodeHeader(facesContext, titledItem, responseWriter, HeaderStates.inactive,
!isActive && !isDisabled);
+ encodeHeader(facesContext, titledItem, responseWriter, HeaderStates.active,
isActive && !isDisabled);
+ encodeHeader(facesContext, titledItem, responseWriter, HeaderStates.disable,
isDisabled);
responseWriter.endElement("div");
}
- private void encodeHeader(FacesContext facesContext, UIComponent component,
ResponseWriter writer,
- String state, Boolean isDisplay) throws IOException {
+ private void encodeHeader(FacesContext facesContext, AbstractTogglePanelTitledItem
component, ResponseWriter writer,
+ HeaderStates state, Boolean isDisplay) throws IOException
{
writer.startElement("div", component);
@@ -134,11 +136,11 @@
writer.writeAttribute("style", "display : none", null);
}
- String name = "headerClass" + capitalize(state);
+ String name = "headerClass" + capitalize(state.toString());
writer.writeAttribute("class", "rf-aci-h-" + state + "
" + attributeAsString(component, name), name);
- UIComponent headerFacet = component.getFacet("header" +
capitalize(state));
+ UIComponent headerFacet = component.getHeaderFacet(state);
if (headerFacet != null && headerFacet.isRendered()) {
headerFacet.encodeAll(facesContext);
} else {
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -39,9 +39,8 @@
/**
* @author akolonitsky
- * @since 2010-08-05
*/
-@ResourceDependencies( { // TODO review
+@ResourceDependencies( {
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -25,6 +25,7 @@
import org.ajax4jsf.javascript.JSObject;
import org.richfaces.component.AbstractCollapsiblePanel;
import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.component.AbstractTogglePanelTitledItem;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -32,9 +33,11 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.richfaces.component.AbstractCollapsiblePanel.States.*;
import static org.richfaces.component.util.HtmlUtil.concatClasses;
import static org.richfaces.component.util.HtmlUtil.concatStyles;
@@ -104,11 +107,13 @@
protected Map<String, Object> getScriptObjectOptions(FacesContext context,
UIComponent component) {
AbstractTogglePanel panel = (AbstractTogglePanel) component;
- Map<String, Object> options = super.getScriptObjectOptions(context,
component);
+ Map<String, Object> options = new HashMap<String, Object>();
+ options.put("activeItem", panel.getActiveItem());
+ options.put("ajax", getAjaxOptions(context, panel));
options.put("switchMode", panel.getSwitchType());
-// TogglePanelRenderer.addEventOption(context, panel, options, SWITCH);
-// TogglePanelRenderer.addEventOption(context, panel, options, BEFORE_SWITCH);
+ TogglePanelRenderer.addEventOption(context, panel, options, SWITCH);
+ TogglePanelRenderer.addEventOption(context, panel, options, BEFORE_SWITCH);
return options;
}
@@ -119,18 +124,18 @@
writer.writeAttribute("class", concatClasses("rf-cp-hr",
attributeAsString(component, "headerClass")), null);
AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
- encodeHeader(context, component, writer, "expanded",
panel.isExpanded());
- encodeHeader(context, component, writer, "collapsed",
!panel.isExpanded());
+ encodeHeader(context, component, writer, expanded, panel.isExpanded());
+ encodeHeader(context, component, writer, collapsed, !panel.isExpanded());
writer.endElement("div");
}
- private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter
responseWriter, String state, boolean isVisible) throws IOException {
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter
responseWriter, AbstractCollapsiblePanel.States state, boolean isVisible) throws
IOException {
responseWriter.startElement("div", component);
responseWriter.writeAttribute("class", "rf-cp-hr-" + state,
null);
responseWriter.writeAttribute("style",
concatStyles(styleElement("display", isVisible ? "" :
"none"), attributeAsString(component, "headerClass")), null);
- UIComponent header = component.getFacet("header" + capitalize(state));
+ UIComponent header = AbstractTogglePanelTitledItem.getHeaderFacet(component,
state);
if (header != null && header.isRendered()) {
header.encodeAll(context);
} else {
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -86,7 +86,7 @@
* @return Capitalized string.
* @throws IllegalArgumentException String is <kk>null</kk> or empty.
*/
- protected static String capitalize(final String string) {
+ public static String capitalize(final String string) {
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-01
08:15:07 UTC (rev 19057)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-01
08:33:51 UTC (rev 19058)
@@ -22,7 +22,6 @@
package org.richfaces.view.facelets.html;
-import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.event.ItemChangeEvent;
import org.richfaces.event.ItemChangeListener;
import org.richfaces.event.ItemChangeSource;
@@ -31,14 +30,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
-import javax.faces.view.EditableValueHolderAttachedObjectHandler;
-import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.TagAttribute;
-import javax.faces.view.facelets.TagAttributeException;
import javax.faces.view.facelets.TagConfig;
-import javax.faces.view.facelets.TagException;
-import javax.faces.view.facelets.TagHandler;
import java.io.Serializable;
/**
@@ -46,90 +39,24 @@
* @author akolonitsky
* @version 1.0
*/
-public final class ItemChangeListenerHandler extends TagHandler implements
EditableValueHolderAttachedObjectHandler {
+public final class ItemChangeListenerHandler extends EventListenerHandler {
- private static class LazyItemChangeListener implements ItemChangeListener,
Serializable {
+ private static class LazyItemChangeListener extends
LazyEventListener<ItemChangeListener> implements ItemChangeListener, Serializable {
+ private static final long serialVersionUID = 7715606467989165179L;
- private static final long serialVersionUID = 1L;
-
- private final String type;
-
- private final ValueExpression binding;
-
LazyItemChangeListener(String type, ValueExpression binding) {
- this.type = type;
- this.binding = binding;
+ super(type, binding);
}
- public void processItemChange(ItemChangeEvent event)
- throws AbortProcessingException {
-
- FacesContext faces = FacesContext.getCurrentInstance();
- if (faces == null) {
- return;
- }
-
- ItemChangeListener instance = null;
- if (this.binding != null) {
- instance = (ItemChangeListener) binding.getValue(faces.getELContext());
- }
- if (instance == null && this.type != null) {
- try {
- instance = (ItemChangeListener) forName(this.type).newInstance();
- } catch (Exception e) {
- throw new AbortProcessingException("Couldn't Lazily
instantiate ItemChangeListener", e);
- }
- if (this.binding != null) {
- binding.setValue(faces.getELContext(), instance);
- }
- }
- if (instance != null) {
- instance.processItemChange(event);
- }
+ public void processItemChange(ItemChangeEvent event) throws
AbortProcessingException {
+ processEvent(event);
}
}
- private final TagAttribute binding;
-
- private final String listenerType;
-
public ItemChangeListenerHandler(TagConfig config) {
super(config);
- this.binding = this.getAttribute("binding");
- TagAttribute type = this.getAttribute("type");
- if (type != null) {
- if (type.isLiteral()) {
- try {
- forName(type.getValue());
- } catch (ClassNotFoundException e) {
- throw new TagAttributeException(type, "Couldn't qualify
ItemChangeListener", e);
- }
- } else {
- throw new TagAttributeException(type, "Must be a literal class name
of type ItemChangeListener");
- }
- this.listenerType = type.getValue();
- } else {
- this.listenerType = null;
- }
}
- public void apply(FaceletContext ctx, UIComponent parent) {
-
- // only process if it's been created
- if (parent == null || !ComponentHandler.isNew(parent)) {
- return;
- }
-
- if (parent instanceof AbstractTogglePanel) {
- applyAttachedObject(ctx.getFacesContext(), parent);
- } else if (UIComponent.isCompositeComponent(parent)) {
- // Allow the composite component to know about the target component.
- TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
- } else {
- throw new TagException(this.tag, "Parent is not of type
AbstractTogglePanel, type is: " + parent);
- }
- }
-
public void applyAttachedObject(FacesContext context, UIComponent parent) {
ValueExpression valueExpr = null;
if (this.binding != null) {
@@ -140,18 +67,5 @@
ItemChangeSource evh = (ItemChangeSource) parent;
evh.addItemChangeListener(new LazyItemChangeListener(this.listenerType,
valueExpr));
}
-
- public String getFor() {
- TagAttribute attr = this.getAttribute("for");
- return attr == null ? null : attr.getValue();
- }
-
- public static Class<?> forName(String name) throws ClassNotFoundException {
- if (null == name || "".equals(name)) {
- return null;
- }
-
- return Class.forName(name, false,
Thread.currentThread().getContextClassLoader());
- }
}