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/02/23 18:11:30 UTC
svn commit: r380157 -
/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
Author: werpu
Date: Thu Feb 23 09:11:27 2006
New Revision: 380157
URL: http://svn.apache.org/viewcvs?rev=380157&view=rev
Log:
fixed a bug in which the registration was done incorrectly
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
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=380157&r1=380156&r2=380157&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 Thu Feb 23 09:11:27 2006
@@ -36,8 +36,7 @@
{
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
- RendererUtils.checkParamValidity(facesContext, uiComponent,
- StateChangedNotifier.class);
+ RendererUtils.checkParamValidity(facesContext, uiComponent, StateChangedNotifier.class);
StateChangedNotifier notifier = (StateChangedNotifier) uiComponent;
@@ -53,8 +52,8 @@
//DojoUtils.addRequire(facesContext, "dojo.xml.Parse");
AddResource addResource = AddResourceFactory.getInstance(facesContext);
- addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN,
- StateChangedNotifierRenderer.class, "stateChangedNotifier.js");
+ addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, StateChangedNotifierRenderer.class,
+ "stateChangedNotifier.js");
encodeJavascript(facesContext, notifier);
@@ -66,37 +65,39 @@
String notifierClientId = notifier.getClientId(facesContext);
String replacedClientId = notifierClientId.replaceAll(":", "_");
- String initFunctionName = "init_"+replacedClientId;
+ String initFunctionName = "init_" + replacedClientId;
UIForm form = getParentForm(notifier);
String formId = form.getClientId(facesContext);
- String notifierVar = replacedClientId+"Notifier";
+ String notifierVar = replacedClientId + "Notifier";
StringBuffer sb = new StringBuffer();
sb.append("<!--\n");
- sb.append("dojo.addOnLoad(window, '"+initFunctionName+"');\n");
- sb.append("function "+initFunctionName+ "() {\n");
- sb.append(notifierVar+" = new org.apache.myfaces.StateChangedNotifier('"+notifierVar+"','"+formId+"','"+notifierClientId+"','"+notifier.getConfirmationMessage()+"',");
+ sb.append("var " + notifierVar + " = null;\n");
+
+ sb.append("function " + initFunctionName + "() {\n");
+ sb.append(notifierVar + " = new org_apache_myfaces_StateChangedNotifier('" + notifierVar + "','" + formId
+ + "','" + notifierClientId + "','" + notifier.getConfirmationMessage() + "',");
String excludedCommandIds = notifier.getExcludedIds();
if (excludedCommandIds != null)
{
- sb.append("'"+excludedCommandIds+"');\n");
+ sb.append("'" + excludedCommandIds + "');\n");
}
else
{
sb.append("'');\n");
}
- sb.append(replacedClientId+"Notifier.prepareNotifier();\n");
+ sb.append(replacedClientId + "Notifier.prepareNotifier();\n");
sb.append("}\n");
+ sb.append("dojo.addOnLoad(window, '" + initFunctionName + "');\n");
sb.append("-->\n");
AddResource addResource = AddResourceFactory.getInstance(facesContext);
- addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN,
- sb.toString());
+ addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, sb.toString());
}
/**
@@ -105,10 +106,12 @@
* @param component
* @return UIForm
*/
- private UIForm getParentForm(UIComponent component) {
+ private UIForm getParentForm(UIComponent component)
+ {
// See if we are in a form
UIComponent parent = component.getParent();
- while (parent != null && !(parent instanceof UIForm)) {
+ while (parent != null && !(parent instanceof UIForm))
+ {
parent = parent.getParent();
}
return (UIForm) parent;