myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1452904 - in /myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag: MenuCommandRenderer.java TabGroupRenderer.java
Date Tue, 05 Mar 2013 17:22:01 GMT
Author: lofwyr
Date: Tue Mar  5 17:22:01 2013
New Revision: 1452904

URL: http://svn.apache.org/r1452904
Log:
TOBAGO-1237: Menu should not need an id

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java?rev=1452904&r1=1452903&r2=1452904&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
Tue Mar  5 17:22:01 2013
@@ -69,8 +69,6 @@ public class MenuCommandRenderer extends
     boolean disabled = menu.isDisabled();
     boolean firstLevel = RendererTypes.MENU_BAR.equals(menu.getParent().getRendererType());
     LabelWithAccessKey label = new LabelWithAccessKey(menu);
-    String clientId = menu.getClientId(facesContext);
-    String submit = HtmlRendererUtils.createSubmitAction(clientId, true, null, null);
 
     if (menu.getFacet(Facets.CHECKBOX) != null) {
       // checkbox menu
@@ -79,12 +77,16 @@ public class MenuCommandRenderer extends
       String image = checked ? "image/MenuCheckmark.gif" : null;
       String hiddenId = checkbox.getClientId(facesContext);
       // the function toggles true <-> false
+      String clientId = menu.getClientId(facesContext);
+      String submit = HtmlRendererUtils.createSubmitAction(clientId, true, null, null);
       String setValue = JQueryUtils.selectId(hiddenId) 
           + ".each(function(){jQuery(this).val(jQuery(this).val() == 'true' ? 'false' : 'true')});
";
       encodeItem(facesContext, writer, menu, label, setValue + submit, disabled, firstLevel,
image);
       encodeHidden(writer, hiddenId, checked);
     } else if (menu.getFacet(Facets.RADIO) != null) {
       // radio menu
+      String clientId = menu.getClientId(facesContext);
+      String submit = HtmlRendererUtils.createSubmitAction(clientId, true, null, null);
       UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
       List<SelectItem> items = RenderUtils.getSelectItems(radio);
       String hiddenId = radio.getClientId(facesContext);
@@ -93,6 +95,7 @@ public class MenuCommandRenderer extends
         String image = checked ? "image/MenuRadioChecked.gif" : null;
         final String labelText = item.getLabel();
         label.reset();
+
         if (labelText != null) {
           if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
             label.setup(labelText);
@@ -111,8 +114,12 @@ public class MenuCommandRenderer extends
       // normal menu command
       CommandRendererHelper helper = new CommandRendererHelper(facesContext, menu);
       String onclick = helper.getOnclick();
+      if (onclick == null) {
+        String clientId = menu.getClientId(facesContext);
+        onclick = HtmlRendererUtils.createSubmitAction(clientId, true, null, null);
+      }
       String image = menu.getImage();
-      encodeItem(facesContext, writer, menu, label, onclick != null ? onclick : submit, disabled,
firstLevel, image);
+      encodeItem(facesContext, writer, menu, label, onclick, disabled, firstLevel, image);
     }
   }
 
@@ -132,8 +139,8 @@ public class MenuCommandRenderer extends
       String onclick, boolean disabled, boolean firstLevel, String image) throws IOException
{
 
     writer.startElement(HtmlElements.LI, null);
-    if (component != null) {
-        writer.writeIdAttribute(component.getClientId(facesContext));
+    if (component != null && !component.isTransient()) {
+      writer.writeIdAttribute(component.getClientId(facesContext));
     }
     Markup markup = null;
     if (component != null) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=1452904&r1=1452903&r2=1452904&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
Tue Mar  5 17:22:01 2013
@@ -256,9 +256,10 @@ public class TabGroupRenderer extends La
 
     // all: sub menu to select any tab directly
     UICommand all = (UICommand) CreateComponentUtils.createComponent(
-        facesContext, UICommand.COMPONENT_TYPE, null);
+        facesContext, UICommand.COMPONENT_TYPE, null, null);
     UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
-        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU);
+        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, null);
+    menu.setTransient(true);
     FacetUtils.setDropDownMenu(all, menu);
     int index = 0;
     for (UIComponent child : tabGroup.getChildren()) {
@@ -266,7 +267,8 @@ public class TabGroupRenderer extends La
         UITab tab = (UITab) child;
         if (tab.isRendered()) {
           UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
-              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, "entry-"
+ index);
+              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, null);
+          entry.setTransient(true);
           LabelWithAccessKey label = new LabelWithAccessKey(tab);
           entry.setLabel(label.getText());
           if (tab.isDisabled()) {



Mime
View raw message