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/07/03 22:59:49 UTC

svn commit: r791013 - in /myfaces/tobago/trunk/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/ standard/src/main/resources/org/apa...

Author: bommel
Date: Fri Jul  3 20:59:49 2009
New Revision: 791013

URL: http://svn.apache.org/viewvc?rev=791013&view=rev
Log:
(TOBAGO-748) <tc:command> with <facet name="change"> inside of selectOneChoice lost focus after action

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.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/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=791013&r1=791012&r2=791013&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Fri Jul  3 20:59:49 2009
@@ -409,6 +409,12 @@
       RenderUtil.encode(facesContext, hidden);
     }
 
+    String lastFocusIdParameter = component.getClientId(facesContext) + SUBCOMPONENT_SEP + "lastFocusId";
+    String lastFocusId = (String) facesContext.getExternalContext().getRequestParameterMap().get(lastFocusIdParameter);
+    if (lastFocusId != null) {
+      writer.writeJavascript("Tobago.lastFocusId = '" + lastFocusId + "';");
+    }
+
     //checkForCommandFacet(component, facesContext, writer);
 
 // TODO: this is needed for the "BACK-BUTTON-PROBLEM"

Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java?rev=791013&r1=791012&r2=791013&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java Fri Jul  3 20:59:49 2009
@@ -913,7 +913,9 @@
         writer.write(facetComponent.getClientId(facesContext));
         writer.write("', ");
         writer.write(Boolean.toString(ComponentUtil.getBooleanAttribute(facetComponent, Attributes.TRANSITION)));
-        writer.write(")");
+        writer.write(", null, '");
+        writer.write(clientId);
+        writer.write("')");
       }
       writer.write("});\n}");
       writer.endJavascript();

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?rev=791013&r1=791012&r2=791013&view=diff
==============================================================================
--- 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 Fri Jul  3 20:59:49 2009
@@ -115,6 +115,8 @@
 
   errorFocusId:undefined,
 
+  lastFocusId: undefined,
+
   htmlIdIndex: 0,
 
   createHtmlId: function() {
@@ -435,6 +437,9 @@
     delete this.page;
     delete this.form;
     delete this.action;
+    delete this.actionPosition;
+    delete this.contextPath;
+    delete this.lastFocusId;
   },
 
   removeEventListeners: function() {
@@ -496,11 +501,16 @@
   /**
     * Submitting the page with specified actionId.
     */
-  submitAction: function(source, actionId, transition, target) {
+  submitAction: function(source, actionId, transition, target, focus) {
     if (transition === undefined || transition == null) {
       transition = true;
     }
 
+    if (focus) {
+      var lastFocusId = this.createInput("hidden", this.page.id + this.SUB_COMPONENT_SEP + 'lastFocusId', focus);
+      this.form.appendChild(lastFocusId);
+    }
+
     Tobago.setActionPosition(source);
 
     if (Tobago.openPopups.length > 0 ) {
@@ -1199,7 +1209,14 @@
     * no element is explicitly requested.
     */
   setFocus: function() {
-    var elementId = this.errorFocusId == "undefined" ? this.focusId: this.errorFocusId;
+    var elementId;
+    if (this.lastFocusId !== undefined) {
+      elementId = this.lastFocusId;
+    } else if (this.errorFocusId !== undefined) {
+      elementId = this.errorFocusId;
+    } else {
+      elementId = this.focusId;
+    }
     var focusElement = this.element(elementId);
     if ((focusElement == "undefined" || !focusElement) && elementId) {
       // search for input elements in tc:select*  controls