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/11/01 16:56:24 UTC
svn commit: r469945 - in /myfaces/tobago/trunk/theme:
scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/
Author: weber
Date: Wed Nov 1 07:56:23 2006
New Revision: 469945
URL: http://svn.apache.org/viewvc?view=rev&rev=469945
Log:
working on TOBAGO-167 (Enable rendering popups by ajax request)
Modified:
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/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=469945&r1=469944&r2=469945
==============================================================================
--- 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 Wed Nov 1 07:56:23 2006
@@ -25,10 +25,13 @@
import org.apache.commons.logging.LogFactory;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_POPUP_RESET;
import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
+import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UIPopup;
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
import org.apache.myfaces.tobago.renderkit.RendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -40,7 +43,7 @@
import javax.faces.context.ResponseWriter;
import java.io.IOException;
-public class PopupRenderer extends RendererBase {
+public class PopupRenderer extends RendererBase implements AjaxRenderer {
private static final Log LOG = LogFactory.getLog(PopupRenderer.class);
@@ -91,14 +94,14 @@
if (ClientProperties.getInstance(facesContext).getUserAgent().isMsie()) {
writer.startElement(HtmlConstants.IFRAME, component);
writer.writeIdAttribute(clientId + SUBCOMPONENT_SEP + HtmlConstants.IFRAME);
- writer.writeClassAttribute("tobago-popup-iframe");
+ writer.writeClassAttribute("tobago-popup-iframe tobago-popup-none");
writer.writeAttribute(HtmlAttributes.STYLE, contentStyle.toString(), null);
writer.writeAttribute(HtmlAttributes.SRC, "javascript:false;", null);
writer.endElement(HtmlConstants.IFRAME);
}
writer.startElement(HtmlConstants.DIV, component);
writer.writeIdAttribute(contentDivId);
- writer.writeClassAttribute("tobago-popup-content");
+ writer.writeClassAttribute("tobago-popup-content tobago-popup-none");
writer.writeAttribute(HtmlAttributes.STYLE, contentStyle.toString(), null);
@@ -119,6 +122,14 @@
if (ComponentUtil.getBooleanAttribute(component, ATTR_POPUP_RESET)) {
component.setRendered(false);
}
+ }
+
+ public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
+ AjaxUtils.checkParamValidity(facesContext, component, UIPopup.class);
+
+ RenderUtil.encode(facesContext, component);
+
+ facesContext.responseComplete();
}
}
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=469945&r1=469944&r2=469945
==============================================================================
--- 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 Wed Nov 1 07:56:23 2006
@@ -750,12 +750,22 @@
*
*/
closePopup: function(id) {
- var divs = Tobago.page.getElementsByTagName("DIV");
- for (var i = 0; i < divs.length; i++) {
- var div = divs[i];
- if (id.indexOf(div.id) == 0 && div.className.indexOf("tobago-popup-default") != -1) {
- Tobago.page.removeChild(div);
- return;
+ var div = Tobago.element(id + "parentDiv");
+ if (div) {
+ // created by ajax
+ div.parentNode.removeChild(div);
+ } else {
+ div = Tobago.element(id);
+ if (div) {
+ div.parentNode.removeChild(div);
+ }
+ div = Tobago.element(id + "content");
+ if (div) {
+ div.parentNode.removeChild(div);
+ }
+ div = Tobago.element(id + "iframe");
+ if (div) {
+ div.parentNode.removeChild(div);
}
}
},
@@ -768,14 +778,13 @@
}
div = document.createElement('div');
- div.id = popupId;
- div.className = "tobago-popup-default";
+ div.id = popupId + "parentDiv";
+ div.className = "tobago-popup-parent";
Tobago.page.appendChild(div);
- div = Tobago.element(popupId);
- Tobago.addAjaxComponent(popupId);
- Tobago.reloadComponent(popupId, actionId, {});
+ Tobago.addAjaxComponent(popupId, div.id);
+ Tobago.reloadComponent(popupId, actionId, {createOverlay: false});
},
// -------- Util functions ----------------------------------------------------