You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/06/13 23:53:18 UTC

svn commit: r667663 - in /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist: AbstractHtmlSelectManyPicklist.java HtmlPicklistRenderer.java

Author: lu4242
Date: Fri Jun 13 14:53:17 2008
New Revision: 667663

URL: http://svn.apache.org/viewvc?rev=667663&view=rev
Log:
TOMAHAWK-424 Gives control over text and sie of the add / remove buttons of SelectManyPicklist and TOMAHAWK-820 New attribute addButtonStyleClass in Sandbox SelectManyPicklist

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/AbstractHtmlSelectManyPicklist.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/AbstractHtmlSelectManyPicklist.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/AbstractHtmlSelectManyPicklist.java?rev=667663&r1=667662&r2=667663&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/AbstractHtmlSelectManyPicklist.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/AbstractHtmlSelectManyPicklist.java Fri Jun 13 14:53:17 2008
@@ -31,11 +31,52 @@
  * @author Bruno Aranda (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class AbstractHtmlSelectManyPicklist extends HtmlSelectManyListbox
+public abstract class AbstractHtmlSelectManyPicklist extends HtmlSelectManyListbox
 {
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlSelectManyPicklist";
     public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PicklistRenderer";
     
+    /**
+     * Define the text that goes inside the add button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getAddButtonText();
+    
+    /**
+     * Define the text that goes inside the remove button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getRemoveButtonText();
+    
+    /**
+     * CSS style to be applied to the button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getAddButtonStyle();
+    
+    /**
+     * CSS style to be applied to the button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getRemoveButtonStyle();
+    
+    /**
+     * CSS styleClass to be applied to the button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getAddButtonStyleClass();
+    
+    /**
+     * CSS styleClass to be applied to the button
+     * 
+     * @JSFProperty
+     */
+    public abstract String getRemoveButtonStyleClass();
     
 }
  
\ No newline at end of file

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java?rev=667663&r1=667662&r2=667663&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java Fri Jun 13 14:53:17 2008
@@ -121,6 +121,20 @@
 
         HtmlSelectManyPicklist picklist = (HtmlSelectManyPicklist) uiComponent;
 
+        String addButtonText = picklist.getAddButtonText();
+        String removeButtonText = picklist.getRemoveButtonText();
+        String addButtonStyle = picklist.getAddButtonStyle();
+        String removeButtonStyle = picklist.getRemoveButtonStyle();
+        String addButtonStyleClass = picklist.getAddButtonStyleClass();
+        String removeButtonStyleClass = picklist.getRemoveButtonStyleClass();
+        
+        //Set the default values for addButtonText and removeButtonText
+        if(addButtonText == null || addButtonText.length() == 0)
+            addButtonText = ">";
+		
+        if(removeButtonText == null || removeButtonText.length() == 0)
+            removeButtonText = "<";
+
         encodeJavascript(facesContext, uiComponent);
 
         String availableListClientId = uiComponent.getClientId(facesContext)
@@ -167,13 +181,13 @@
                                               + "','" + hiddenFieldCliendId + "')";
 
         encodeSwapButton(facesContext, uiComponent, javascriptAddToSelected,
-                         ">");
+                addButtonText, addButtonStyle, addButtonStyleClass);
 
         writer.startElement(HTML.BR_ELEM, uiComponent);
         writer.endElement(HTML.BR_ELEM);
 
-        encodeSwapButton(facesContext, uiComponent,
-                         javascriptRemoveFromSelected, "<");
+        encodeSwapButton(facesContext, uiComponent, javascriptRemoveFromSelected, 
+                removeButtonText, removeButtonStyle, removeButtonStyleClass);
 
         writer.endElement(HTML.TD_ELEM);
 
@@ -203,12 +217,15 @@
     }
 
     private void encodeSwapButton(FacesContext facesContext,
-                                  UIComponent uiComponent, String javaScriptFunction, String text)
+                                  UIComponent uiComponent, String javaScriptFunction,
+                                  String text, String style, String styleClass)
             throws IOException
     {
         ResponseWriter writer = facesContext.getResponseWriter();
 
         writer.startElement(HTML.INPUT_ELEM, uiComponent);
+		writer.writeAttribute(HTML.STYLE_ATTR, style, null);
+		writer.writeAttribute(HTML.CLASS_ATTR, styleClass, null);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_BUTTON,
                               JSFAttr.TYPE_ATTR);
         writer.writeAttribute(HTML.ONCLICK_ATTR, javaScriptFunction, null);