You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pr...@apache.org on 2005/11/22 22:13:15 UTC
svn commit: r348251 - in /myfaces/sandbox/trunk: conf/
src/java/org/apache/myfaces/custom/ajax/api/
src/java/org/apache/myfaces/custom/ajax/util/
src/java/org/apache/myfaces/custom/inputAjax/
src/java/org/apache/myfaces/custom/util/ tld/
Author: prophecy
Date: Tue Nov 22 13:13:10 2005
New Revision: 348251
URL: http://svn.apache.org/viewcvs?rev=348251&view=rev
Log:
- added SelectBooleanAjax component
- added Sandbox message tag
- rolled back some changes to UIComponentTag
Added:
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlMessageTag.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxTag.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/ComponentUtils.java
Modified:
myfaces/sandbox/trunk/conf/faces-config.xml
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxTag.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java
myfaces/sandbox/trunk/tld/myfaces_sandbox.tld
Modified: myfaces/sandbox/trunk/conf/faces-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/conf/faces-config.xml?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/conf/faces-config.xml (original)
+++ myfaces/sandbox/trunk/conf/faces-config.xml Tue Nov 22 13:13:10 2005
@@ -45,6 +45,11 @@
</component>
<component>
+ <component-type>org.apache.myfaces.SelectBooleanCheckboxAjax</component-type>
+ <component-class>org.apache.myfaces.custom.inputAjax.HtmlSelectBooleanCheckboxAjax</component-class>
+ </component>
+
+ <component>
<component-type>org.apache.myfaces.Planner</component-type>
<component-class>org.apache.myfaces.custom.schedule.HtmlPlanner</component-class>
</component>
@@ -83,7 +88,7 @@
<component-type>org.apache.myfaces.Scope</component-type>
<component-class>org.apache.myfaces.custom.scope.UIScope</component-class>
</component>
-
+
<component>
<component-type>org.apache.myfaces.HtmlSelectManyPicklist</component-type>
<component-class>org.apache.myfaces.custom.picklist.HtmlSelectManyPicklist</component-class>
@@ -148,6 +153,13 @@
<renderer-class>org.apache.myfaces.custom.inputAjax.HtmlInputTextAjaxRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>javax.faces.SelectBoolean</component-family>
+ <renderer-type>org.apache.myfaces.CheckboxAjax</renderer-type>
+ <renderer-class>org.apache.myfaces.custom.inputAjax.HtmlSelectBooleanCheckboxAjaxRenderer</renderer-class>
+ </renderer>
+
+
<renderer>
<component-family>javax.faces.Panel</component-family>
@@ -197,13 +209,13 @@
<renderer-type>script.aculo.us.renderer</renderer-type>
<renderer-class>org.apache.myfaces.custom.effect.EffectRenderer</renderer-class>
</renderer>
-
+
<renderer>
<component-family>javax.faces.SelectMany</component-family>
<renderer-type>org.apache.myfaces.PicklistRenderer</renderer-type>
<renderer-class>org.apache.myfaces.custom.picklist.HtmlPicklistRenderer</renderer-class>
</renderer>
-
+
</render-kit>
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java Tue Nov 22 13:13:10 2005
@@ -2,23 +2,26 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.custom.buffer.HtmlBufferResponseWriterWrapper;
-import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.application.jsp.JspStateManagerImpl;
import org.apache.myfaces.application.ComponentNotFoundException;
-import org.apache.myfaces.util.DebugUtils;
+import org.apache.myfaces.application.jsp.JspStateManagerImpl;
+import org.apache.myfaces.custom.util.ComponentUtils;
+import org.apache.myfaces.renderkit.RendererUtils;
+import org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl;
-import javax.faces.event.PhaseListener;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
-import javax.servlet.http.HttpServletResponse;
-import java.io.PrintWriter;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.servlet.ServletResponse;
+import java.io.Writer;
import java.io.IOException;
+import java.util.Map;
/**
+ * This short circuits the life cycle and applies updates to affected components only
+ *
* User: treeder
* Date: Oct 26, 2005
* Time: 6:03:21 PM
@@ -44,13 +47,14 @@
{
log.debug("In AjaxDecodePhaseListener beforePhase");
FacesContext context = event.getFacesContext();
-
- if (context.getExternalContext().getRequestParameterMap().containsKey("affectedAjaxComponent"))
+ Map externalRequestMap = context.getExternalContext().getRequestParameterMap();
+ if(externalRequestMap.containsKey("affectedAjaxComponent"))
{
UIViewRoot root = context.getViewRoot();
//DebugUtils.printView(root, System.out);
String affectedAjaxComponent = (String) context.getExternalContext().getRequestParameterMap().get("affectedAjaxComponent");
- UIComponent ajaxComponent = root.findComponent(affectedAjaxComponent);
+
+ UIComponent ajaxComponent = ComponentUtils.findComponent(context, root, affectedAjaxComponent);
if (ajaxComponent == null)
{
String msg = "Component with id [" + affectedAjaxComponent + "] not found in view tree.";
@@ -75,28 +79,59 @@
log.error("Found component is no ajaxComponent : " + RendererUtils.getPathToComponent(ajaxComponent));
}
+
+
+ // NOW TRYING TO DO THE ENCODE THAT WAS IN AJAXPHASELISTENER RIGHT HERE, THEN ENDING RESPONSE
+ if (ajaxComponent instanceof AjaxComponent)
+ {
+ try
+ {
+ // TR - What is this HtmlBufferResponseWriterWrapper stuff for???? This caused me hours and hours of pain
+ if (context.getResponseWriter() == null)
+ {
+ ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
+ Writer htmlResponseWriter = response.getWriter();
+ context.setResponseWriter(new HtmlResponseWriterImpl(htmlResponseWriter, "text/html", "UTF-8"));
+ }
+ ((AjaxComponent) ajaxComponent).encodeAjax(context);
+ }
+ catch (IOException e)
+ {
+ log.error("Exception while rendering ajax-response", e);
+ }
+ }
+ else
+ {
+ log.error("Found component is no ajaxComponent : " + RendererUtils.getPathToComponent(ajaxComponent));
+ }
+
+ if (!context.getApplication().getStateManager().isSavingStateInClient(context))
+ {
+ ((JspStateManagerImpl) context.getApplication().getStateManager()).saveSerializedView(context);
+ }
+ context.responseComplete();
}
}
- public static Object getValueForComponent(FacesContext facesContext, UIComponent component)
+ public static Object getValueForComponent(FacesContext context, UIComponent component)
{
- String possibleClientId = component.getClientId(facesContext);
+ String possibleClientId = component.getClientId(context);
- if (facesContext.getExternalContext().getRequestParameterMap().containsKey(possibleClientId))
+ if (context.getExternalContext().getRequestParameterMap().containsKey(possibleClientId))
{
- return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
+ return context.getExternalContext().getRequestParameterMap().get(possibleClientId);
}
else
{
- possibleClientId = (String) facesContext.getExternalContext().getRequestParameterMap().get(
+ possibleClientId = (String) context.getExternalContext().getRequestParameterMap().get(
"affectedAjaxComponent");
log.debug("affectedAjaxComponent: " + possibleClientId);
- UIViewRoot root = facesContext.getViewRoot();
- UIComponent ajaxComponent = root.findComponent(possibleClientId);
+ UIViewRoot root = context.getViewRoot();
+ UIComponent ajaxComponent = ComponentUtils.findComponent(context, root, possibleClientId);
if (ajaxComponent == component)
{
- return facesContext.getExternalContext().getRequestParameterMap().get(possibleClientId);
+ return context.getExternalContext().getRequestParameterMap().get(possibleClientId);
}
else
{
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/api/AjaxPhaseListener.java Tue Nov 22 13:13:10 2005
@@ -18,21 +18,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.application.jsp.JspStateManagerImpl;
-import org.apache.myfaces.custom.buffer.HtmlBufferResponseWriterWrapper;
+import org.apache.myfaces.custom.util.ComponentUtils;
import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletResponse;
import java.io.IOException;
-import java.io.PrintWriter;
import java.io.Writer;
/**
@@ -66,7 +63,7 @@
UIViewRoot root = facesContext.getViewRoot();
UIComponent ajaxComponent =
- root.findComponent(possibleClientId);
+ ComponentUtils.findComponent(facesContext, root, possibleClientId);
if (ajaxComponent == component)
{
@@ -80,16 +77,18 @@
}
}
+
+
public void afterPhase(PhaseEvent event)
{
log.debug("In AjaxPhaseListener afterPhase");
- FacesContext context = event.getFacesContext();
+ /*FacesContext context = event.getFacesContext();
if (context.getExternalContext().getRequestParameterMap().containsKey("affectedAjaxComponent"))
{
UIViewRoot root = context.getViewRoot();
String clientId = (String)context.getExternalContext().getRequestParameterMap().get("affectedAjaxComponent");
- UIComponent ajaxComponent = root.findComponent(clientId);
+ UIComponent ajaxComponent = ComponentUtils.findComponentFullTree(context, root, clientId); //root.findComponent(clientId);
log.debug("affectedAjaxComponent: " + ajaxComponent + " - " + ajaxComponent.getId());
if (ajaxComponent instanceof AjaxComponent)
@@ -122,7 +121,7 @@
((JspStateManagerImpl) context.getApplication().getStateManager()).saveSerializedView(context);
}
context.responseComplete();
- }
+ }*/
}
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java Tue Nov 22 13:13:10 2005
@@ -6,6 +6,7 @@
import org.apache.myfaces.renderkit.html.HtmlMessageRendererBase;
import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
import org.apache.myfaces.custom.ajax.AjaxCallbacks;
+import org.apache.myfaces.custom.util.ComponentUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -89,8 +90,6 @@
.append(" el.value = \"\";\n")
.append("}\n");
out.writeText(buff.toString(), null);
-
-
}
out.writeText("var " + jsNameSpace + "ajaxUrl = '" + ajaxURL + "';\n", null);
@@ -108,15 +107,18 @@
.append(" //alert(\"originalRequest: \" + originalRequest + \" - \" + successful + \"\\ntext: \" + originalRequest.responseText);\n")
.append(" var errorArray = originalRequest.responseXML.getElementsByTagName(\"response\")[0].getElementsByTagName(\"error\");\n")
.append(" if(errorArray && errorArray.length > 0){\n")
- // could easily loop this and handle more than one error at a time, but that wouldn't happen now
+ // could easily loop this and handle more than one error at a time
.append(" var myObError = errorArray[0];\n")
.append(" var errorClientId = myObError.getAttribute(\"elname\");\n")
.append(" var errorSeverity = myObError.getAttribute(\"severity\");\n")
.append(" var errorSummary = myObError.getAttribute(\"summary\");\n")
+ .append(" var errorDetail = null;")
+ .append(" var errorDetailElements = myObError.getElementsByTagName(\"detail\");\n")
+ .append(" if(errorDetailElements) errorDetail = errorDetailElements[0].text;")
.append(" var style = myObError.getAttribute(\"style\");\n")
.append(" var styleClass = myObError.getAttribute(\"styleClass\");\n")
.append(" ")
- .append(jsNameSpace).append("displayError(errorClientId, errorSeverity, errorSummary, styleClass, style);\n")
+ .append(jsNameSpace).append("displayError(errorClientId, errorSeverity, errorSummary, errorDetail, styleClass, style);\n")
.append(" }\n")
.append(" var myObElementArray = originalRequest.responseXML.getElementsByTagName(\"response\")[0].getElementsByTagName(\"elementUpdated\");\n")
.append(" if(myObElementArray && myObElementArray.length > 0){")
@@ -125,7 +127,8 @@
.append(" var elvalue = myObElement.getAttribute(\"elvalue\");\n")
.append(" if (successful)\n")
.append(" {\n");
- if (component.getOnSuccess() != null) {
+ if (component.getOnSuccess() != null)
+ {
buff.append(" ").append(jsNameSpace).append("onSuccessFunction(elname, elvalue);\n");
}
buff.append(" ").append(jsNameSpace).append("clearError(elname);\n");
@@ -137,12 +140,14 @@
buff.append(" }\n").append(" }\n").append("}\n");
// displayError function shows any errors sent back
- buff.append("function ").append(jsNameSpace).append("displayError(elname, severity, summary, styleClass, style){\n")
+ buff.append("function ").append(jsNameSpace).append("displayError(elname, severity, summary, detail, styleClass, style){\n")
.append(" var msgSpan = document.getElementById(\"msgFor_\" + elname);\n")
.append(" if(msgSpan){\n")
- .append(" msgSpan.innerHTML = summary;\n")
+ .append(" var summaryAndDetail = summary;")
+ .append(" if(detail) summaryAndDetail += \": \" + detail;") // be nice to make the details in a tooltip
+ .append(" msgSpan.innerHTML = summaryAndDetail;\n")
.append(" if(styleClass) msgSpan.className = styleClass;\n")
- //.append(" if(style) msgSpan.style = style;") // guess you can't swap out the entire style like this
+ //.append(" if(style) msgSpan.style = style;") // guess you can't swap out the entire style like this
.append(" }\n")
.append("}\n");
// clearError function to remove error display if there was one previously
@@ -262,7 +267,7 @@
String msgForId = "msgFor_" + clientId;
System.out.println("Looking for component: " + msgForId);
- UIComponent msgComponent = context.getViewRoot().findComponent(msgForId);
+ UIComponent msgComponent = ComponentUtils.findComponent(context, context.getViewRoot(), msgForId);
if (msgComponent != null)
{
System.out.println("Component found");
@@ -282,8 +287,15 @@
if (styleClass != null) buff.append("\" styleClass=\"").append(styleClass);
if (style != null) buff.append("\" style=\"").append(style);
buff.append("\" summary=\"").append(msg.getSummary())
- .append("\" />");
- buff.append("\n");
+ .append("\" >\n");
+ String detail = msg.getDetail();
+ if (detail != null)
+ {
+ buff.append("<detail>");
+ buff.append(msg.getDetail());
+ buff.append("</detail>\n");
+ }
+ buff.append("</error>\n");
hasErrorMessages = true;
}
if (!hasErrorMessages)
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjax.java Tue Nov 22 13:13:10 2005
@@ -10,9 +10,6 @@
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
-import java.util.Map;
-import java.util.Collection;
-import java.util.Iterator;
import java.io.IOException;
/**
@@ -31,7 +28,7 @@
private String onStart;
private Boolean showOkButton = new Boolean(false);
private String okText;
- private Boolean showCancelText = new Boolean(true); // might want to just remove this and assume it's the case
+ private Boolean showCancelButton = new Boolean(true); // might want to just remove this and always show cancel button
private String cancelText;
public HtmlInputTextAjax()
@@ -83,7 +80,7 @@
values[3] = onStart;
values[4] = showOkButton;
values[5] = okText;
- values[6] = showCancelText;
+ values[6] = showCancelButton;
values[7] = cancelText;
return ((Object) (values));
}
@@ -97,7 +94,7 @@
onStart = (String) values[3];
showOkButton = (Boolean) values[4];
okText = (String) values[5];
- showCancelText = (Boolean) values[6];
+ showCancelButton = (Boolean) values[6];
cancelText = (String) values[7];
}
@@ -151,14 +148,14 @@
this.okText = okText;
}
- public Boolean getShowCancelText()
+ public Boolean getShowCancelButton()
{
- return showCancelText;
+ return showCancelButton;
}
- public void setShowCancelText(Boolean showCancelText)
+ public void setShowCancelButton(Boolean showCancelButton)
{
- this.showCancelText = showCancelText;
+ this.showCancelButton = showCancelButton;
}
public String getCancelText()
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java Tue Nov 22 13:13:10 2005
@@ -13,12 +13,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.component.UIComponent;
-import javax.faces.application.FacesMessage;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Iterator;
/**
* User: treeder
@@ -93,7 +88,7 @@
writer.writeAttribute(HTML.VALUE_ATTR, okText, null);
writer.writeAttribute(HTML.ONCLICK_ATTR, submitFunctionStart, null);
writer.endElement(HTML.INPUT_TYPE_BUTTON);
- if(comp.getShowCancelText() != null && comp.getShowCancelText().booleanValue()){
+ if(comp.getShowCancelButton() != null && comp.getShowCancelButton().booleanValue()){
// put a space here
writer.write(" ");
writer.startElement(HTML.ANCHOR_ELEM, comp);
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxTag.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxTag.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxTag.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxTag.java Tue Nov 22 13:13:10 2005
@@ -2,7 +2,6 @@
import org.apache.myfaces.taglib.html.ext.HtmlInputTextTag;
import org.apache.myfaces.custom.ajax.AjaxCallbacks;
-import org.apache.myfaces.component.html.ext.HtmlInputText;
import javax.faces.component.UIComponent;
@@ -18,7 +17,7 @@
private String onStart;
private String showOkButton;
private String okText;
- private String showCancelText;
+ private String showCancelButton;
private String cancelText;
public String getComponentType() {
@@ -41,7 +40,7 @@
onStart = null;
showOkButton = null;
okText = null;
- showCancelText = null;
+ showCancelButton = null;
cancelText = null;
}
@@ -54,7 +53,7 @@
setStringProperty(component, "onStart", onStart);
setBooleanProperty(component, "showOkButton", showOkButton);
setStringProperty(component, "okText", okText);
- setBooleanProperty(component, "showCancelText", showCancelText);
+ setBooleanProperty(component, "showCancelButton", showCancelButton);
setStringProperty(component, "cancelText", cancelText);
}
@@ -110,14 +109,14 @@
this.okText = okText;
}
- public String getShowCancelText()
+ public String getShowCancelButton()
{
- return showCancelText;
+ return showCancelButton;
}
- public void setShowCancelText(String showCancelText)
+ public void setShowCancelButton(String showCancelButton)
{
- this.showCancelText = showCancelText;
+ this.showCancelButton = showCancelButton;
}
public String getCancelText()
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlMessageTag.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlMessageTag.java?rev=348251&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlMessageTag.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlMessageTag.java Tue Nov 22 13:13:10 2005
@@ -0,0 +1,47 @@
+package org.apache.myfaces.custom.inputAjax;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.servlet.jsp.JspException;
+
+/**
+ * User: treeder
+ * Date: Nov 22, 2005
+ * Time: 12:10:58 PM
+ */
+public class HtmlMessageTag extends org.apache.myfaces.taglib.html.ext.HtmlMessageTag
+{
+ private static final Log log = LogFactory.getLog(HtmlMessageTag.class);
+
+
+ public void setFor(String aFor)
+ {
+ super.setFor(aFor);
+
+ /* String id = getId();
+ UIComponent comp = getComponentInstance();
+ log.debug("ID WAS: " + id);
+ if (id == null)
+ {
+ // default id so client side scripts can use this (ie: ajax), this will obviously break things if someone specifies an id, so please don't specify an id if using Ajax components!
+ id = "msgFor_" + getFor();
+ log.debug("Setting id on MessageTag: " + id);
+ setId(id);
+ setForceId("true");
+ if(comp != null){
+ log.debug("SETTING COMP ID");
+ comp.setId(id);
+ }
+ }*/
+
+ }
+
+ protected UIComponent findComponent(FacesContext context) throws JspException
+ {
+ log.debug("FINDCOMPONENT");
+ return super.findComponent(context);
+ }
+}
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java?rev=348251&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjax.java Tue Nov 22 13:13:10 2005
@@ -0,0 +1,184 @@
+package org.apache.myfaces.custom.inputAjax;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectBooleanCheckbox;
+import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
+import org.apache.myfaces.custom.ajax.AjaxCallbacks;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+import javax.faces.component.EditableValueHolder;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * User: treeder
+ * Date: Nov 21, 2005
+ * Time: 8:47:27 AM
+ */
+public class HtmlSelectBooleanCheckboxAjax extends HtmlSelectBooleanCheckbox implements AjaxComponent, AjaxCallbacks
+{
+
+ private static final Log log = LogFactory.getLog(HtmlSelectBooleanCheckboxAjax.class);
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.SelectBooleanCheckboxAjax";
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.CheckboxAjax";
+
+ private String onSuccess;
+ private String onFailure;
+ private String onStart;
+ private String onImage;
+ private String offImage;
+
+ public HtmlSelectBooleanCheckboxAjax()
+ {
+ super();
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ /**
+ * Decode ajax request and apply value changes
+ *
+ * @param context
+ */
+ public void decodeAjax(FacesContext context)
+ {
+ log.debug("entering HtmlSelectBooleanCheckboxAjax.decodeAjax");
+
+ // Handled differently
+ Map requestParams = context.getExternalContext().getRequestParameterMap();
+ String checkedStr = (String) requestParams.get("checked");
+ log.debug("checked: " + checkedStr);
+ boolean checked = Boolean.valueOf(checkedStr).booleanValue();
+ if (checked)
+ {
+ HtmlRendererUtils.decodeUISelectBoolean(context, this);
+ }
+ else
+ {
+ // needs special handling
+ decodeUISelectBoolean(context, this);
+ }
+ //System.out.println("SUBMITTED VALUE: " + ((EditableValueHolder) this).getSubmittedValue());
+ validate(context);
+ updateModel(context);
+
+ //String elname = (String) requestParams.get("elname");
+ //String elvalue = (String) requestParams.get("elvalue");
+
+ if (log.isDebugEnabled())
+ {
+ Object valOb = this.getValue();
+ valOb = this.getValue();
+ log.debug("value object after decodeAjax: " + valOb);
+ }
+
+ }
+
+ private void decodeUISelectBoolean(FacesContext facesContext, HtmlSelectBooleanCheckboxAjax component)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(facesContext)
+ + " is not an EditableValueHolder");
+ }
+ ((EditableValueHolder) component).setSubmittedValue(Boolean.FALSE);
+
+ }
+
+ public void encodeAjax(FacesContext context) throws IOException
+ {
+ log.debug("entering HtmlSelectBooleanCheckboxAjax.encodeAjax");
+ if (context == null) throw new NullPointerException("context");
+ if (!isRendered()) return;
+ Renderer renderer = getRenderer(context);
+
+ if (renderer != null && renderer instanceof AjaxRenderer)
+ {
+ ((AjaxRenderer) renderer).encodeAjax(context, this);
+ }
+ else
+ {
+ log.warn("Renderer does not implement AjaxRenderer! " + renderer);
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ Object values[] = new Object[6];
+ values[0] = super.saveState(context);
+ values[1] = onSuccess;
+ values[2] = onFailure;
+ values[3] = onStart;
+ values[4] = onImage;
+ values[5] = offImage;
+ return ((Object) (values));
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ onSuccess = (String) values[1];
+ onFailure = (String) values[2];
+ onStart = (String) values[3];
+ onImage = (String) values[4];
+ offImage = (String) values[5];
+
+ }
+
+ public String getOnSuccess()
+ {
+ return onSuccess;
+ }
+
+ public void setOnSuccess(String onSuccess)
+ {
+ this.onSuccess = onSuccess;
+ }
+
+ public String getOnFailure()
+ {
+ return onFailure;
+ }
+
+ public void setOnFailure(String onFailure)
+ {
+ this.onFailure = onFailure;
+ }
+
+ public String getOnStart()
+ {
+ return onStart;
+ }
+
+ public void setOnStart(String onStart)
+ {
+ this.onStart = onStart;
+ }
+
+ public String getOnImage()
+ {
+ return onImage;
+ }
+
+ public void setOnImage(String onImage)
+ {
+ this.onImage = onImage;
+ }
+
+ public String getOffImage()
+ {
+ return offImage;
+ }
+
+ public void setOffImage(String offImage)
+ {
+ this.offImage = offImage;
+ }
+
+}
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java?rev=348251&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java Tue Nov 22 13:13:10 2005
@@ -0,0 +1,95 @@
+package org.apache.myfaces.custom.inputAjax;
+
+import org.apache.myfaces.renderkit.html.ext.HtmlCheckboxRenderer;
+import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.renderkit.RendererUtils;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.ajax.util.AjaxRendererUtils;
+import org.apache.myfaces.component.html.util.AddResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UISelectMany;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * User: treeder
+ * Date: Nov 21, 2005
+ * Time: 9:09:20 AM
+ */
+public class HtmlSelectBooleanCheckboxAjaxRenderer extends HtmlCheckboxRenderer implements AjaxRenderer
+{
+ private static final Log log = LogFactory.getLog(HtmlSelectBooleanCheckboxAjaxRenderer.class);
+ private static final String JAVASCRIPT_ENCODED = "org.apache.myfaces.custom.inputAjax.HtmlSelectBooleanCheckboxAjax.JAVASCRIPT_ENCODED";
+
+
+ /**
+ * Encodes any stand-alone javascript functions that are needed.
+ * Uses either the extension filter, or a
+ * user-supplied location for the javascript files.
+ *
+ * @param context FacesContext
+ * @param component UIComponent
+ * @throws java.io.IOException
+ */
+ private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
+ {
+
+ HtmlSelectBooleanCheckboxAjax selectBooleanCheckbox = (HtmlSelectBooleanCheckboxAjax) component;
+
+ // Add prototype script to header
+ AddResource addResource = AddResource.getInstance(context);
+ AjaxRendererUtils.addPrototypeScript(context, component, addResource);
+
+ // write required javascript
+ ResponseWriter out = context.getResponseWriter();
+ String extraParams =("&checked=\" + el.checked + \"");
+ AjaxRendererUtils.writeAjaxScript(context, out, selectBooleanCheckbox, extraParams);
+
+ // set request var that says what it's going to do
+ context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
+ }
+
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+ {
+ RendererUtils.checkParamValidity(context, component, HtmlSelectBooleanCheckboxAjax.class);
+ if (HtmlRendererUtils.isDisplayValueOnly(component) || isDisabled(context, component))
+ {
+ super.encodeEnd(context, component);
+ return;
+ }
+
+ String clientId = component.getClientId(context);
+ HtmlSelectBooleanCheckboxAjax selectBooleanCheckbox = (HtmlSelectBooleanCheckboxAjax) component;
+
+ // allow for user defined onclick's as well
+ String onClick = selectBooleanCheckbox.getOnclick();
+ if(onClick == null){
+ onClick = "";
+ }
+ onClick = component.getId() + "_MyFaces_inputAjax_ajaxSubmit2(this, '" + clientId + "'); " + onClick;
+ selectBooleanCheckbox.setOnclick(onClick);
+
+ this.encodeJavascript(context, component);
+ super.encodeEnd(context, component);
+ }
+
+ public void encodeAjax(FacesContext context, UIComponent component) throws IOException
+ {
+ log.debug("entering HtmlSelectBooleanCheckboxAjaxRenderer.encodeAjax");
+ // check for request type (portlet support)
+ HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
+ Map extraReturnAttributes = new HashMap();
+ extraReturnAttributes.put("checked", request.getParameter("checked"));
+ AjaxRendererUtils.encodeAjax(context, component, extraReturnAttributes);
+ }
+}
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxTag.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxTag.java?rev=348251&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxTag.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxTag.java Tue Nov 22 13:13:10 2005
@@ -0,0 +1,105 @@
+package org.apache.myfaces.custom.inputAjax;
+
+import org.apache.myfaces.taglib.html.ext.HtmlSelectBooleanCheckboxTag;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * User: treeder
+ * Date: Nov 21, 2005
+ * Time: 8:47:50 AM
+ */
+public class HtmlSelectBooleanCheckboxAjaxTag extends HtmlSelectBooleanCheckboxTag
+{
+ private String onSuccess;
+ private String onFailure;
+ private String onStart;
+ private String onImage;
+ private String offImage;
+
+ public String getComponentType() {
+ return HtmlSelectBooleanCheckboxAjax.COMPONENT_TYPE;
+ }
+
+ /**
+ * @return the RendererType String
+ */
+ public String getRendererType() {
+ return HtmlSelectBooleanCheckboxAjax.DEFAULT_RENDERER_TYPE;
+ }
+
+
+ public void release()
+ {
+ super.release();
+ onSuccess = null;
+ onFailure = null;
+ onStart = null;
+ onImage = null;
+ offImage = null;
+
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ setStringProperty(component, "onSuccess", onSuccess);
+ setStringProperty(component, "onFailure", onFailure);
+ setStringProperty(component, "onStart", onStart);
+ setStringProperty(component, "onImage", onImage);
+ setStringProperty(component, "offImage", offImage);
+
+ }
+
+
+ public String getOnSuccess()
+ {
+ return onSuccess;
+ }
+
+ public void setOnSuccess(String onSuccess)
+ {
+ this.onSuccess = onSuccess;
+ }
+
+ public String getOnFailure()
+ {
+ return onFailure;
+ }
+
+ public void setOnFailure(String onFailure)
+ {
+ this.onFailure = onFailure;
+ }
+
+ public String getOnStart()
+ {
+ return onStart;
+ }
+
+ public void setOnStart(String onStart)
+ {
+ this.onStart = onStart;
+ }
+
+ public String getOnImage()
+ {
+ return onImage;
+ }
+
+ public void setOnImage(String onImage)
+ {
+ this.onImage = onImage;
+ }
+
+ public String getOffImage()
+ {
+ return offImage;
+ }
+
+ public void setOffImage(String offImage)
+ {
+ this.offImage = offImage;
+ }
+}
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjax.java Tue Nov 22 13:13:10 2005
@@ -55,12 +55,12 @@
String elname = (String) requestParams.get("elname");
String elvalue = (String) requestParams.get("elvalue");
String checkedStr = (String) requestParams.get("checked");
- log.debug("checkedStr: " + checkedStr);
+ //log.debug("checkedStr: " + checkedStr);
boolean checked = Boolean.valueOf(checkedStr).booleanValue();
- log.debug("checked: " + checked);
+ //log.debug("checked: " + checked);
// now apply this to the
Object valOb = this.getValue();
- log.debug("valOb: " + valOb);
+ //log.debug("valOb: " + valOb);
if(valOb instanceof Collection){
// then all good
log.debug("valOb is collection");
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/ComponentUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/ComponentUtils.java?rev=348251&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/ComponentUtils.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/util/ComponentUtils.java Tue Nov 22 13:13:10 2005
@@ -0,0 +1,41 @@
+package org.apache.myfaces.custom.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * User: treeder
+ * Date: Nov 21, 2005
+ * Time: 9:20:14 PM
+ */
+public class ComponentUtils
+{
+ private static Log log = LogFactory.getLog(ComponentUtils.class);
+
+ /**
+ * TR- This was moved from AjaxPhaseListenere on checkin 344383
+ *
+ * @param context
+ * @param root
+ * @param clientId
+ * @return component referenced by clientId or null if not found
+ */
+ public static UIComponent findComponent(FacesContext context, UIComponent root, String clientId)
+ {
+ UIComponent component = null;
+ for(int i = 0; i < root.getChildCount() && component == null; i++)
+ {
+ UIComponent child = (UIComponent)root.getChildren().get(i);
+ component = findComponent(context, child, clientId);
+ }
+
+ if(component == null && root.getClientId(context).equals(clientId))
+ {
+ component = root;
+ }
+ return component;
+ }
+}
Modified: myfaces/sandbox/trunk/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/tld/myfaces_sandbox.tld?rev=348251&r1=348250&r2=348251&view=diff
==============================================================================
--- myfaces/sandbox/trunk/tld/myfaces_sandbox.tld (original)
+++ myfaces/sandbox/trunk/tld/myfaces_sandbox.tld Tue Nov 22 13:13:10 2005
@@ -760,11 +760,11 @@
<description>Test for button</description>
</attribute>
<attribute>
- <name>showCancelText</name>
+ <name>showCancelButton</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
- <description>Whether to show cancel text</description>
+ <description>Whether to show cancel button</description>
</attribute>
<attribute>
<name>cancelText</name>
@@ -775,5 +775,108 @@
</attribute>
</tag>
+ <tag>
+ <name>selectBooleanCheckboxAjax</name>
+ <tag-class>org.apache.myfaces.custom.inputAjax.HtmlSelectBooleanCheckboxAjaxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectBooleanCheckbox by user role support.
+ </description>
+ &standard_select_boolean_checkbox_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ &ext_ajax_attributes;
+ <attribute>
+ <name>onImage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Image to show instead of checkox when boolean value is true</description>
+ </attribute>
+ <attribute>
+ <name>offImage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Image to show instead of checkox when boolean value is false</description>
+ </attribute>
+ </tag>
+ <tag>
+ <name>selectBooleanCheckboxAjax</name>
+ <tag-class>org.apache.myfaces.custom.inputAjax.HtmlSelectBooleanCheckboxAjaxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectBooleanCheckbox by user role support.
+ </description>
+ &standard_select_boolean_checkbox_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ &ext_ajax_attributes;
+ <attribute>
+ <name>onImage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Image to show instead of checkox when boolean value is true</description>
+ </attribute>
+ <attribute>
+ <name>offImage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Image to show instead of checkox when boolean value is false</description>
+ </attribute>
+ </tag>
+
+
+ <!-- message, special for ajax stuff to enable client side message updates, could roll this into tomahawk at some point -->
+ <tag>
+ <name>message</name>
+ <tag-class>org.apache.myfaces.custom.inputAjax.HtmlMessageTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ MyFaces extension to the standard messages tag: see summaryDetailSeparator attribute
+ </description>
+ &standard_message_attributes;
+ <!-- MyFaces extensions -->
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ <attribute>
+ <name>summaryFormat</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ If present, instead of rendering the message summary, a MessageFormat with this
+ attribute as pattern is created. The format method of this MessageFormat is
+ called with the message summary as the first argument and the label of the
+ associated component (if any) as the second argument.
+ Example: "{0}:"
+ </description>
+ </attribute>
+ <attribute>
+ <name>detailFormat</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ If present, instead of rendering the message detail, a MessageFormat with this
+ attribute as pattern is created. The format method of this MessageFormat is
+ called with the message detail as the first argument and the label of the
+ associated component (if any) as the second argument.
+ Example: "The input in field {1} is wrong: {0}"
+ </description>
+ </attribute>
+ <attribute>
+ <name>replaceIdWithLabel</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ If present, all occurrences of the id of the component for which the message
+ is rendered will be replaced by the label. Standard is true for the extended
+ message renderer.
+ </description>
+ </attribute>
+ </tag>
</taglib>