myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r471545 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ example/demo/src/main/webapp/overview/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ theme/stan...
Date Sun, 05 Nov 2006 22:14:52 GMT
Author: weber
Date: Sun Nov  5 14:14:51 2006
New Revision: 471545

URL: http://svn.apache.org/viewvc?view=rev&rev=471545
Log:
Working on TOBAGO-167 (Enable rendering popups by ajax request)

make sheetconfig popup working with ajax and reload facet

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java?view=diff&rev=471545&r1=471544&r2=471545
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
Sun Nov  5 14:14:51 2006
@@ -32,6 +32,8 @@
 
   private static final Log LOG = LogFactory.getLog(UIPopup.class);
 
+  public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Popup";
+
   private String width;
   private String height;
   private String left;
@@ -39,7 +41,9 @@
 
   private boolean popupReset;
 
-  public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Popup";
+  private boolean closedOnClient;
+
+  private boolean submitted;
 
   public void processDecodes(FacesContext facesContext) {
     super.processDecodes(facesContext);
@@ -55,6 +59,8 @@
   public void encodeBegin(FacesContext facesContext) throws IOException {
     removeStoredRendered(facesContext);
     super.encodeBegin(facesContext);
+    closedOnClient = false;
+    submitted = false;
   }
 
   public void processValidators(FacesContext context) {
@@ -64,14 +70,18 @@
 
   private void resetAndStoreRendered(FacesContext facesContext) {
     if (popupReset && isRendered()) {
-      ValueBinding vb = getValueBinding(ATTR_RENDERED);
-      if (vb != null) {
-        vb.setValue(facesContext, false);
-      } else {
-        setRendered(false);
+      if (submitted || closedOnClient) {
+        ValueBinding vb = getValueBinding(ATTR_RENDERED);
+        if (vb != null) {
+          vb.setValue(facesContext, false);
+        } else {
+          setRendered(false);
+        }
+      }
+      if (!closedOnClient) {
+        Map map = facesContext.getExternalContext().getRequestMap();
+        map.put(getClientId(facesContext) + "rendered", true);
       }
-      Map map = facesContext.getExternalContext().getRequestMap();
-      map.put(getClientId(facesContext) + "rendered", true);
     }
   }
 
@@ -153,6 +163,15 @@
 
   public void setPopupReset(boolean popupReset) {
     this.popupReset = popupReset;
+  }
+
+
+  public void closedOnClient() {
+    this.closedOnClient = true;
+  }
+
+  public void submitted() {
+    this.submitted = true;
   }
 
   private void addToPage() {

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp?view=diff&rev=471545&r1=471544&r2=471545
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp Sun Nov  5
14:14:51 2006
@@ -100,11 +100,11 @@
                       <tc:gridLayout columns="100px;1*;100px"
                                      marginLeft="10px" marginRight="10px"/>
                     </f:facet>
-                    <tc:button onclick="Tobago.closePopup('page:sheetConfigPopup')"
+                    <tc:button onclick="Tobago.closePopup(this)"
                                label="Cancel" />
 
                     <tc:cell />
-                    <tc:button onclick="Tobago.reloadComponent('page:sheetBox','@autoId',
{});Tobago.closePopup('page:sheetConfigPopup');" 
+                    <tc:button onclick="Tobago.reloadComponent('page:sheetBox','@autoId',
{});Tobago.closePopup(this);"
                         label="Ok" />
                   </tc:cell>
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java?view=diff&rev=471545&r1=471544&r2=471545
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
Sun Nov  5 14:14:51 2006
@@ -27,6 +27,8 @@
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.component.UIPopup;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
@@ -40,15 +42,31 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
+import java.util.Map;
 
 public class PopupRenderer extends RendererBase implements AjaxRenderer {
 
   private static final Log LOG = LogFactory.getLog(PopupRenderer.class);
 
   public static final String CONTENT_ID_POSTFIX = SUBCOMPONENT_SEP + "content";
+  private static final String CLOSED = "closed";
 
   public boolean getRendersChildren() {
     return true;
+  }
+
+
+  public void decode(FacesContext facesContext, UIComponent component) {
+    super.decode(facesContext, component);
+    Map map = facesContext.getExternalContext().getRequestParameterMap();
+    String hidden = (String) map.get(component.getClientId(facesContext));
+    if (CLOSED.equals(hidden)) {
+      ((UIPopup)component).closedOnClient();
+    }
+    UIPage page = ComponentUtil.findPage(component);
+    if (page.getActionId() != null && page.getActionId().startsWith(component.getClientId(facesContext)))
{
+      ((UIPopup)component).submitted();      
+    }
   }
 
   public void encodeBeginTobago(

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?view=diff&rev=471545&r1=471544&r2=471545
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
(original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Sun Nov  5 14:14:51 2006
@@ -691,6 +691,11 @@
     */
   setupPopup: function(id, left, top) {
 //  alert("tobagoSetupPopup('" + id + "', '" + left + "', '"+ top + "')");
+    var hidden = Tobago.element(id + Tobago.SUB_COMPONENT_SEP + "hidden");
+    if (hidden && hidden.type == "hidden") {
+      hidden.parentNode.removeChild(hidden);
+    }
+
     var contentId = id + Tobago.SUB_COMPONENT_SEP + "content";
     var div = this.element(contentId);
     if (div) {
@@ -758,12 +763,27 @@
    * remove a popup without request
    *
    */
-  closePopup: function(id) {
-    var div = Tobago.element(id + "parentDiv");
+  closePopup: function(element) {
+    var div;
+    var id;
+    if (typeof element == "string") {
+      id = element;
+    } else if (typeof element == "object" && element.tagName) {
+      div = Tobago.findAnchestorWithTagName(element, "DIV");
+      while (div && div.className && div.className.indexOf("tobago-popup-content")
== -1) {
+        div = Tobago.findAnchestorWithTagName(div.parentNode, "DIV");
+      }
+      if (div) {
+        var re = new RegExp(Tobago.SUB_COMPONENT_SEP + "content$")
+        id = div.id.replace(re, "");
+      }
+    }
+
+    div = Tobago.element(id + "parentDiv");
     if (div) {
       // created by ajax
       div.parentNode.removeChild(div);
-    } else {
+    } else if (id) {
       div = Tobago.element(id);
       if (div) {
         div.parentNode.removeChild(div);
@@ -776,13 +796,23 @@
       if (div) {
         div.parentNode.removeChild(div);
       }
+    } else {
+      LOG.error("Can't close popup ");
     }
+
+    var hidden = document.createElement("input");
+    hidden.id = id + Tobago.SUB_COMPONENT_SEP + "hidden";
+    hidden.name = id;
+    hidden.type = "hidden";
+    hidden.value = "closed";
+    Tobago.form.appendChild(hidden);
   },
 
   openPopupWithAction: function(popupId, actionId) {
     var div = Tobago.element(popupId);
     if (div) {
-      // something is wrong, doing full reload
+      LOG.warn("something is wrong, doing full reload");
+//      LOG.info("id = " + popupId + "  type = " + div.tagName + "  class = " + div.className);
       Tobago.submitAction(actionId);
     }
 



Mime
View raw message