You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/04/05 22:18:25 UTC
svn commit: r391778 - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier:
StateChangedNotifier.java StateChangedNotifierRenderer.java
StateChangedNotifierTag.java
Author: werpu
Date: Wed Apr 5 13:18:23 2006
New Revision: 391778
URL: http://svn.apache.org/viewcvs?rev=391778&view=rev
Log:
removed several dependencies into myfaces-impl for dependencies
into tomahawk and impl-shared
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifier.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierTag.java
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifier.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifier.java?rev=391778&r1=391777&r2=391778&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifier.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifier.java Wed Apr 5 13:18:23 2006
@@ -15,19 +15,18 @@
*/
package org.apache.myfaces.custom.statechangednotifier;
-import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
-
-import javax.faces.component.html.HtmlInputHidden;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
+
/**
* Shows a confirmation window if some of the input fields of the form have changed its value
* @author Bruno Aranda (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class StateChangedNotifier extends HtmlInputHidden {
+public class StateChangedNotifier extends javax.faces.component.html.HtmlInputHidden {
public static final String COMPONENT_TYPE = "org.apache.myfaces.StateChangedNotifier";
public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.StateChangedNotifierRenderer";
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java?rev=391778&r1=391777&r2=391778&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java Wed Apr 5 13:18:23 2006
@@ -15,30 +15,44 @@
*/
package org.apache.myfaces.custom.statechangednotifier;
-import org.apache.commons.lang.StringUtils;
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.ConverterException;
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.custom.dojo.DojoConfig;
import org.apache.myfaces.custom.dojo.DojoUtils;
-import org.apache.myfaces.renderkit.html.HtmlHiddenRenderer;
import org.apache.myfaces.renderkit.html.util.AddResource;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
/**
* @author Bruno Aranda (latest modification by $Author$)
- * @version $Revision$ $Date$
+ * @version $Revision$ $Date: 2006-04-02 22:03:33 +0200 (So, 02 Apr
+ * 2006) $
*/
-public class StateChangedNotifierRenderer extends HtmlHiddenRenderer {
+public class StateChangedNotifierRenderer extends HtmlRenderer {
+
+ public void decode(FacesContext facesContext, UIComponent component) {
+ RendererUtils.checkParamValidity(facesContext, component, null);
+
+ if (component instanceof UIInput) {
+ HtmlRendererUtils.decodeUIInput(facesContext, component);
+ } else {
+ throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
+ }
+ }
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
RendererUtils.checkParamValidity(facesContext, uiComponent, StateChangedNotifier.class);
@@ -51,32 +65,18 @@
return;
}
- String javascriptLocation = (String) notifier.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- DojoUtils.addMainInclude(facesContext, uiComponent, javascriptLocation, new DojoConfig());
- DojoUtils.addRequire(facesContext, uiComponent, "dojo.widget.Dialog");
- DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
-
- //DojoUtils.addRequire(facesContext, "dojo.xml.Parse");
-
- writeDialog(facesContext, uiComponent);
-
- AddResource addResource = AddResourceFactory.getInstance(facesContext);
+ renderInitialization(facesContext, uiComponent, notifier);
- if (!DojoUtils.isInlineScriptSet(facesContext, "stateChangedNotifier.js"))
- addResource.addJavaScriptHere(facesContext, StateChangedNotifierRenderer.class, "stateChangedNotifier.js");
-
- String styleLocation = (String) uiComponent.getAttributes().get(JSFAttr.STYLE_LOCATION);
+ encodeJavascript(facesContext, notifier);
+ //We have to render on our own to avoid dependencies into myfaces-impl
+ renderInputHidden(facesContext, uiComponent);
- //we need a style def for the dialog system
- if (StringUtils.isNotBlank(styleLocation)) {
- addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, styleLocation + "/default.css");
- } else {
- addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, StateChangedNotifierRenderer.class, "css/default.css");
- }
+ }
- encodeJavascript(facesContext, notifier);
+ public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException {
+ RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
- super.encodeEnd(facesContext, uiComponent);
+ return RendererUtils.getConvertedUIOutputValue(facesContext, (UIOutput) uiComponent, submittedValue);
}
private void encodeJavascript(FacesContext facesContext, StateChangedNotifier notifier) {
@@ -103,7 +103,7 @@
sb.append("'');\n");
}
- sb.append("setTimeout('"+replacedClientId +"Notifier.prepareNotifier()',2000);\n");
+ sb.append("setTimeout('" + replacedClientId + "Notifier.prepareNotifier()',2000);\n");
sb.append("}\n");
@@ -129,9 +129,55 @@
return (UIForm) parent;
}
+ private void renderInitialization(FacesContext facesContext, UIComponent uiComponent, StateChangedNotifier notifier)
+ throws IOException {
+ String javascriptLocation = (String) notifier.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ DojoUtils.addMainInclude(facesContext, uiComponent, javascriptLocation, new DojoConfig());
+ DojoUtils.addRequire(facesContext, uiComponent, "dojo.widget.Dialog");
+ DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
+
+ // DojoUtils.addRequire(facesContext, "dojo.xml.Parse");
+
+ writeDialog(facesContext, uiComponent);
+
+ AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
+ if (!DojoUtils.isInlineScriptSet(facesContext, "stateChangedNotifier.js"))
+ addResource.addJavaScriptHere(facesContext, StateChangedNotifierRenderer.class, "stateChangedNotifier.js");
+
+ String styleLocation = (String) uiComponent.getAttributes().get(JSFAttr.STYLE_LOCATION);
+
+ // we need a style def for the dialog system
+ if (StringUtils.isNotBlank(styleLocation)) {
+ addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, styleLocation + "/default.css");
+ } else {
+ addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, StateChangedNotifierRenderer.class, "css/default.css");
+ }
+ }
+
+ private void renderInputHidden(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+ RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ writer.startElement(HTML.INPUT_ELEM, uiComponent);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+
+ String clientId = uiComponent.getClientId(facesContext);
+ writer.writeAttribute(HTML.ID_ATTR, clientId, null);
+ writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
+
+ String value = RendererUtils.getStringValue(facesContext, uiComponent);
+
+ if (value != null) {
+ writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
+ }
+
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
/**
- * dialog definition
- * this one is needed for the dojoized dialog
+ * dialog definition this one is needed for the dojoized dialog
*
* @param facesContext
* @param uiComponent
@@ -139,15 +185,12 @@
*/
private void writeDialog(FacesContext facesContext, UIComponent uiComponent) throws IOException {
/*
- * <div id="form1__idJsp1Notifier_Dialog" style="position:absolute; visibility: hidden;">
- <div id="form1__idJsp1Notifier_Dialog_Content">
- values have changed do you really want to
- <br>
- submit the values
- </div>
- <input type="button" id="form1__idJsp1Notifier_Dialog_Yes" value="yes" />
- <input type="button" id="form1__idJsp1Notifier_Dialog_No" value="no" />
- * </div>
+ * <div id="form1__idJsp1Notifier_Dialog" style="position:absolute;
+ * visibility: hidden;"> <div id="form1__idJsp1Notifier_Dialog_Content">
+ * values have changed do you really want to <br> submit the values
+ * </div> <input type="button" id="form1__idJsp1Notifier_Dialog_Yes"
+ * value="yes" /> <input type="button"
+ * id="form1__idJsp1Notifier_Dialog_No" value="no" /> </div>
*/
String notifierClientId = uiComponent.getClientId(facesContext);
@@ -166,19 +209,19 @@
writer.startElement(HTML.DIV_ELEM, uiComponent);
writer.writeAttribute(HTML.ID_ATTR, dialogVar + "_Content", null);
writer.endElement(HTML.DIV_ELEM);
- writer.write(" ");
+ writer.write(HTML.NBSP_ENTITY);
writer.startElement(HTML.INPUT_ELEM, uiComponent);
- writer.writeAttribute(HTML.TYPE_ATTR, "button", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.BUTTON_ELEM, null);
writer.writeAttribute(HTML.ID_ATTR, dialogVar + "_Yes", null);
writer.writeAttribute(HTML.VALUE_ATTR, yesText, null);
writer.endElement(HTML.INPUT_ELEM);
- writer.write(" ");
+ writer.write(HTML.NBSP_ENTITY);
writer.startElement(HTML.INPUT_ELEM, uiComponent);
writer.writeAttribute(HTML.TYPE_ATTR, "button", null);
writer.writeAttribute(HTML.ID_ATTR, dialogVar + "_No", null);
writer.writeAttribute(HTML.VALUE_ATTR, noText, null);
writer.endElement(HTML.INPUT_ELEM);
writer.endElement(HTML.DIV_ELEM);
- writer.write(" ");
+ writer.write(HTML.NBSP_ENTITY);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierTag.java?rev=391778&r1=391777&r2=391778&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierTag.java Wed Apr 5 13:18:23 2006
@@ -15,16 +15,16 @@
*/
package org.apache.myfaces.custom.statechangednotifier;
-import org.apache.myfaces.taglib.html.HtmlInputHiddenTag;
-
import javax.faces.component.UIComponent;
+import org.apache.myfaces.shared_impl.taglib.html.HtmlInputHiddenTagBase;
+
/**
* @author Bruno Aranda (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class StateChangedNotifierTag extends HtmlInputHiddenTag {
+public class StateChangedNotifierTag extends HtmlInputHiddenTagBase {
private String confirmationMessage;
private String disabled;
private String excludedIds;