You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/08/15 18:33:08 UTC
svn commit: r804483 - in /myfaces/tobago/branches/tobago-1.0.x:
core/src/main/java/org/apache/myfaces/tobago/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarbo...
Author: bommel
Date: Sat Aug 15 16:33:08 2009
New Revision: 804483
URL: http://svn.apache.org/viewvc?rev=804483&view=rev
Log:
(TOBAGO-786) Page submit on window resize
thanks to Helmut Swaczinna for the initial patch
Modified:
myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?rev=804483&r1=804482&r2=804483&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Sat Aug 15 16:33:08 2009
@@ -209,6 +209,7 @@
public static final String FACET_PICKER_POPUP = "pickerPopup";
public static final String FACET_POPUP = "popup";
public static final String FACET_RELOAD = "reload";
+ public static final String FACET_RESIZE_ACTION = "resizeAction";
public static final String FACET_TOOL_BAR = "toolBar";
public static final String FACET_TOOL_BAR_COMMAND = "toolBarCommand";
Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java?rev=804483&r1=804482&r2=804483&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java Sat Aug 15 16:33:08 2009
@@ -36,9 +36,14 @@
uiComponent = "org.apache.myfaces.tobago.component.UIPage",
rendererType = "Page",
facets =
- {@Facet(name = "action", description = "Contains an instance of UICommand (tc:command) for an auto-action"),
- @Facet(name = "menuBar", description = "Menubar"),
- @Facet(name = "layout", description = "Contains an instance of UILayout")})
+ {@Facet(name = "action", description = "Contains an instance of UICommand (tc:command) for an auto-action",
+ allowedChildComponenents = "org.apache.myfaces.tobago.Command"),
+ @Facet(name = "resizeAction",
+ description ="Contains an instance of UICommand (tc:command) or a UIForm (tc:form) with a UICommand"
+ + " for a resize-action",
+ allowedChildComponenents = {"org.apache.myfaces.tobago.Command", "org.apache.myfaces.tobago.Form"}),
+ @Facet(name = "menuBar", description = "Menubar"),
+ @Facet(name = "layout", description = "Contains an instance of UILayout")})
public interface PageTagDeclaration extends TobagoBodyTagDeclaration, HasLabel, HasId, HasDimension, HasBinding,
HasState {
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=804483&r1=804482&r2=804483&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Sat Aug 15 16:33:08 2009
@@ -35,12 +35,14 @@
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TRANSITION;
import static org.apache.myfaces.tobago.TobagoConstants.FACET_ACTION;
import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUBAR;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_RESIZE_ACTION;
import static org.apache.myfaces.tobago.TobagoConstants.FORM_ACCEPT_CHARSET;
import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UILayout;
import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.component.UIPopup;
+import org.apache.myfaces.tobago.component.UIForm;
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.renderkit.PageRendererBase;
@@ -59,6 +61,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIComponent;
+import javax.faces.component.UICommand;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -340,7 +343,21 @@
page.getOnloadScripts().add("setTimeout(\"" + action + "\", " + duration + ");\n");
}
}
- StringBuilder script = new StringBuilder();
+
+ if (component.getFacets().containsKey(FACET_RESIZE_ACTION)) {
+ UIComponent facet = component.getFacet(FACET_RESIZE_ACTION);
+ UIComponent command = null;
+ if (facet instanceof UICommand) {
+ command = facet;
+ } else if (facet instanceof UIForm && facet.getChildCount() == 1) {
+ command = (UIComponent) facet.getChildren().get(0);
+ }
+ if (command != null && command.isRendered()) {
+ writer.writeJavascript("Tobago.resizeActionId = '" + command.getClientId(facesContext) + "';");
+ }
+ }
+
+ StringBuilder script = new StringBuilder(128);
// onload script
writeEventFunction(script, page.getOnloadScripts(), "load", false);
@@ -376,7 +393,7 @@
writer.writeClassAttribute();
writer.writeIdAttribute(clientId);
- StringBuilder images = new StringBuilder();
+ StringBuilder images = new StringBuilder(256);
images.append("Tobago.pngFixBlankImage = '");
images.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/blank.gif"));
images.append("';\n");
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=804483&r1=804482&r2=804483&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Sat Aug 15 16:33:08 2009
@@ -80,31 +80,31 @@
/**
* the html body object of current page.
- * set via init fuction (onload attribute of body)
+ * set via init function (onload attribute of body)
*/
page: null,
/**
* The html form object of current page.
- * set via init fuction (onload attribute of body)
+ * set via init function (onload attribute of body)
*/
form: null,
/**
* The hidden html input object for submitted actionId.
- * set via init fuction (onload attribute of body)
+ * set via init function (onload attribute of body)
*/
action: null,
/**
* The hidden html input object for the contextPath.
- * set via init fuction (onload attribute of body)
+ * set via init function (onload attribute of body)
*/
contextPath: null,
/**
- * The id ot the element which should became the focus after loading.
+ * The id of the element which should became the focus after loading.
* Set via renderer if requested.
*/
focusId: undefined,
@@ -113,6 +113,12 @@
lastFocusId: undefined,
+ /**
+ * The id ot the action which should be executed when the window was resized.
+ */
+ resizeActionId: undefined,
+ resizeEventCount: 0,
+
htmlIdIndex: 0,
createHtmlId: function() {
@@ -276,6 +282,10 @@
this.addBindEventListener(document, "keypress", this.acceleratorKeys, "observe");
+ if (Tobago.resizeActionId) {
+ window.setTimeout(Tobago.registerResizeAction, 1000);
+ }
+
window.setTimeout(Tobago.finishPageLoading, 1);
TbgTimer.endOnload = new Date();
},
@@ -291,6 +301,10 @@
TbgTimer.log();
},
+ registerResizeAction: function() {
+ Tobago.addEventListener(window, "resize", Tobago.resizePage);
+ },
+
onSubmit: function() {
if (Tobago.applicationOnsubmit) {
var result = Tobago.applicationOnsubmit();
@@ -1164,6 +1178,18 @@
Tobago.reloadComponent2(source, popupId, actionId, options);
},
+ resizePage: function(event) {
+ Tobago.resizeEventCount++;
+ window.setTimeout(Tobago.resizePageAction, 250);
+ },
+
+ resizePageAction: function() {
+ Tobago.resizeEventCount--;
+ if (Tobago.resizeEventCount == 0) {
+ Tobago.submitAction(Tobago.resizeActionId);
+ }
+ },
+
// -------- Util functions ----------------------------------------------------
clickOnElement: function(id) {