myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmarinsc...@apache.org
Subject svn commit: r548842 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ examples/src/main/java/org/apache/myfaces/examples/ppr/ examples/src/main/webapp/
Date Tue, 19 Jun 2007 20:29:43 GMT
Author: mmarinschek
Date: Tue Jun 19 13:29:42 2007
New Revision: 548842

URL: http://svn.apache.org/viewvc?view=rev&rev=548842
Log:
TOMAHAWK-1028: enable inputs submitting a ppr-panelgroup - iin a data-table as well

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupDataTable.jsp

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js?view=diff&rev=548842&r1=548841&r2=548842
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
Tue Jun 19 13:29:42 2007
@@ -29,13 +29,13 @@
     this.showDebugMessages = showDebugMessages;
     this.stateUpdate = stateUpdate;
 
-    if(typeof window.myFacesPartialTriggers == "undefined")
+    if(typeof window.oamPartialTriggersToZoneIds == "undefined")
 	{
-    	window.myFacesPartialTriggers = new Array;
+    	window.oamPartialTriggersToZoneIds = new Array;
     }
-    if(typeof window.myFacesPartialTriggerPatterns == "undefined")
+    if(typeof window.oamZoneIdsToPartialTriggerPatterns == "undefined")
 	{
-    	window.myFacesPartialTriggerPatterns = new Array;
+    	window.oamZoneIdsToPartialTriggerPatterns = new Array;
     }
     if(typeof window.myFacesInlineLoadingMessage == "undefined")
 	{
@@ -44,7 +44,7 @@
 
     this.replaceFormSubmitFunction(formId);
 
-    this.addButtonOnClickHandlers();
+    this.addElementEventHandler();
 }
 
 //Method to register individual HTML to be displayed instead of the component during loading
@@ -58,24 +58,26 @@
 
 org.apache.myfaces.PPRCtrl.prototype.addPartialTriggerPattern= function(pattern, refreshZoneId)
 {
-        window.myFacesPartialTriggerPatterns[refreshZoneId] = pattern;
+        window.oamZoneIdsToPartialTriggerPatterns[refreshZoneId] = pattern;
 };
 
 //Method for JSF Components to register their Partial Triggers
 
 org.apache.myfaces.PPRCtrl.prototype.addPartialTrigger= function(inputElementId, refreshZoneId)
 {
-    if (window.myFacesPartialTriggers[inputElementId] === undefined)
+    if (window.oamPartialTriggersToZoneIds[inputElementId] === undefined)
     {
-        window.myFacesPartialTriggers[inputElementId] = refreshZoneId;
+        window.oamPartialTriggersToZoneIds[inputElementId] = refreshZoneId;
     }
     else
     {
-        window.myFacesPartialTriggers[inputElementId] =
-        window.myFacesPartialTriggers[inputElementId] +
+        window.oamPartialTriggersToZoneIds[inputElementId] =
+        window.oamPartialTriggersToZoneIds[inputElementId] +
         "," +
         refreshZoneId;
     }
+
+    this._addEventHandler(dojo.byId(inputElementId));
 };
 
 // registering a function (called before submit) on each form to block periodical refresh
during request-response cycle
@@ -136,7 +138,7 @@
 			domElement.innerHTML = componentUpdate.firstChild.data;
 		}
 	    //ensure that new buttons in the ParitalUpdate also have onclick-handlers
-	    this.formNode.myFacesPPRCtrl.addButtonOnClickHandlers();
+	    this.formNode.myFacesPPRCtrl.addElementEventHandler();
 
         if (this.formNode.myFacesPPRCtrl.stateUpdate)
         {
@@ -352,48 +354,88 @@
 //TODO: event connect
 //This Method defines joinpoints for all inputs of either type submit or image
 
-org.apache.myfaces.PPRCtrl.prototype.addButtonOnClickHandlers = function()
+org.apache.myfaces.PPRCtrl.prototype.addElementEventHandler = function()
 {
     if (typeof this.form == "undefined" || this.form.tagName.toLowerCase() != "form")
     {
         return;
     }
 
-        formButtons = new Array();
-        for (var i = 0; i < this.form.elements.length; i++)
-        {
-            if (this.form.elements[i].tagName.toLowerCase() == "input" &&
-                (this.form.elements[i].type.toLowerCase() == "submit" ||
-                 this.form.elements[i].type.toLowerCase() == "image")
-                )
-            {
-            formButtons.push(this.form.elements[i]);
-            }
+    for (var i = 0; i < this.form.elements.length; i++)
+    {
+        var formElement = this.form.elements[i];
+        if(this._isButton(formElement)) {
+            this._addEventHandler(formElement);
         }
+    }
+}
 
-        for (var i = 0; i < formButtons.length; i++)
-        {
-            var button = formButtons[i];
-            if(typeof button.onclick_orig == "undefined")
-            {
-                button.onclick_orig = button.onclick;
-                button.onclick = this.buttonOnClickHandler;
-                button.myFacesPPRCtrl=this;
-            }
+org.apache.myfaces.PPRCtrl.prototype._addEventHandler = function (formElement) {
+    if (this._isButton(formElement) || this._isCheckbox(formElement) || this._isRadio(formElement))
{
+        this._addOnClickHandler(formElement);
+    }
+    else if(this._isText(formElement) || this._isDropdown(formElement)) {
+        this._addOnChangeHandler(formElement);
+    }
+}
 
-        }
+org.apache.myfaces.PPRCtrl.prototype._isDropdown = function (formElement) {
+    return formElement.tagName.toLowerCase() == "select";
+}
+
+org.apache.myfaces.PPRCtrl.prototype._isButton = function (formElement) {
+    return formElement.tagName.toLowerCase() == "input" &&
+                (formElement.type.toLowerCase() == "submit" ||
+                 formElement.type.toLowerCase() == "image");
+}
 
+org.apache.myfaces.PPRCtrl.prototype._isText = function (formElement) {
+    return formElement.tagName.toLowerCase() == "input" &&
+                (formElement.type.toLowerCase() == "text" );
 }
 
+org.apache.myfaces.PPRCtrl.prototype._isCheckbox = function (formElement) {
+    return formElement.tagName.toLowerCase() == "input" &&
+                (formElement.type.toLowerCase() == "checkbox" );
+}
+
+org.apache.myfaces.PPRCtrl.prototype._isRadio = function (formElement) {
+    return formElement.tagName.toLowerCase() == "input" &&
+                (formElement.type.toLowerCase() == "radio" );
+}
+
+org.apache.myfaces.PPRCtrl.prototype._addOnClickHandler = function (formElement) {
+
+    if(typeof formElement.oam_onevent_orig == "undefined")
+    {
+        formElement.oam_onevent_orig = formElement.onclick;
+        formElement.onclick = this.elementOnEventHandler;
+        formElement.myFacesPPRCtrl=this;
+    }
+
+}
+
+org.apache.myfaces.PPRCtrl.prototype._addOnChangeHandler = function (formElement) {
+
+    if(typeof formElement.oam_onevent_orig == "undefined")
+    {
+        formElement.oam_onevent_orig = formElement.onchange;
+        formElement.onchange = this.elementOnEventHandler;
+        formElement.myFacesPPRCtrl=this;
+    }
+
+}
+
+
 //PointCutAdvisor which invokes the AJAX Submit Method of the PPR Controller after custom
 //onclick-handlers for submit-buttons and submit-images
 
-org.apache.myfaces.PPRCtrl.prototype.buttonOnClickHandler = function (_event)
+org.apache.myfaces.PPRCtrl.prototype.elementOnEventHandler = function (_event)
 {
-    if(this.onclick_orig.type != "undefined")
+    if(typeof this.oam_onevent_orig != "undefined")
     {
-        if(this.onclick_orig() == false)
-		return false;
+        if(this.oam_onevent_orig()==false)
+		    return false;
     }
     return this.myFacesPPRCtrl.ajaxSubmitFunction(this);
 }
@@ -407,14 +449,14 @@
     if (typeof triggerId != "undefined")
     {
     var retval = null;
-        if (typeof window.myFacesPartialTriggers[triggerId] != "undefined")
+        if (typeof window.oamPartialTriggersToZoneIds[triggerId] != "undefined")
         {
-            retval = window.myFacesPartialTriggers[triggerId];
+            retval = window.oamPartialTriggersToZoneIds[triggerId];
         }
 
-		for (refreshZoneId in window.myFacesPartialTriggerPatterns)
+		for (refreshZoneId in window.oamZoneIdsToPartialTriggerPatterns)
 		{
-			if(this.isMatchingPattern(window.myFacesPartialTriggerPatterns[refreshZoneId],triggerId)
&&
+			if(this.isMatchingPattern(window.oamZoneIdsToPartialTriggerPatterns[refreshZoneId],triggerId)
&&
 				typeof refreshZoneId == "string" )
 				if(retval == null || retval == "")
 				{

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java?view=diff&rev=548842&r1=548841&r2=548842
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
Tue Jun 19 13:29:42 2007
@@ -22,6 +22,7 @@
 import org.apache.myfaces.examples.inputSuggestAjax.Address;
 
 import javax.faces.FacesException;
+import javax.faces.model.SelectItem;
 import javax.faces.component.UIData;
 import javax.faces.event.ValueChangeEvent;
 import java.util.ArrayList;
@@ -54,6 +55,19 @@
 
     public void setCarTable(UIData carTable) {
         _carTable = carTable;
+    }
+
+    public List getTypeList() {
+        List li = new ArrayList();
+
+        List simpleCarList = getSimpleCarList();
+
+        for (Object aSimpleCarList : simpleCarList) {
+            SimpleCar simpleCar = (SimpleCar) aSimpleCarList;
+            li.add(new SelectItem(simpleCar.getType(),simpleCar.getType(),null));
+        }
+
+        return li;
     }
 
     public List getSimpleCarList() {

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?view=diff&rev=548842&r1=548841&r2=548842
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Tue Jun 19 13:29:42 2007
@@ -40,6 +40,7 @@
 	            <h:outputLink value="pprPanelGroupOnChange.jsf" ><f:verbatim>PPRPanelGroup
- using PPR with drop-down and checkbox onChange handlers</f:verbatim></h:outputLink>
 	            <h:outputLink value="pprPanelGroupDataScroller.jsf" ><f:verbatim>PPRPanelGroup
- ajaxifying a datatable using PPR with partialTriggerPattern</f:verbatim></h:outputLink>
                 <h:outputLink value="pprPanelGroupPeriodicalUpdate.jsf" ><f:verbatim>PPRPanelGroup
- parts of a page are getting automatically refreshed by AJAX-Calls (through periodic intervals)</f:verbatim></h:outputLink>
+                <h:outputLink value="pprPanelGroupDataTable.jsf" ><f:verbatim>PPRPanelGroup
- parts of a page are getting manually refreshed in a dataTable</f:verbatim></h:outputLink>
             </h:panelGrid>
             <h:outputText value="Resource Serving"/>
             <h:panelGrid style="padding-left:25px">

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupDataTable.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupDataTable.jsp?view=diff&rev=548842&r1=548841&r2=548842
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupDataTable.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupDataTable.jsp Tue
Jun 19 13:29:42 2007
@@ -58,17 +58,19 @@
                 <f:facet name="header">
                     <h:outputText value="Type"/>
                 </f:facet>
-                <h:inputText value="#{carDetail.type}" immediate="true" valueChangeListener="#{pprExampleBean.typeChanged}"/>
+                <h:selectOneMenu id="type" value="#{carDetail.type}" immediate="true"
valueChangeListener="#{pprExampleBean.typeChanged}">
+                    <f:selectItems value="#{pprExampleBean.typeList}"/>
+                </h:selectOneMenu>
             </h:column>
             <h:column>
                 <f:facet name="header">
                     <h:outputText value="Color"/>
                 </f:facet>
-                <h:inputText value="#{carDetail.color}" immediate="true" valueChangeListener="#{pprExampleBean.colorChanged}"/>
+                <h:inputText value="#{carDetail.color}" id="color" immediate="true" valueChangeListener="#{pprExampleBean.colorChanged}"/>
             </h:column>
             <h:column>
                 <h:commandButton id="update"/>
-                <s:pprPanelGroup id="carEntryUpdate" partialTriggers="update">
+                <s:pprPanelGroup id="carEntryUpdate" partialTriggers="update,type,color">
                     <h:panelGrid columns="2">
                       <h:outputText value="Id"/>
                       <h:outputText value="#{carDetail.id}"/>



Mime
View raw message