[richfaces-svn-commits] JBoss Rich Faces SVN: r5701 - in trunk/sandbox/ui/pickList/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jan 29 09:22:06 EST 2008


Author: vmolotkov
Date: 2008-01-29 09:22:06 -0500 (Tue, 29 Jan 2008)
New Revision: 5701

Modified:
   trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
   trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickList.js
   trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickListSI.js
Log:
pickList component

Modified: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java	2008-01-29 14:14:23 UTC (rev 5700)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java	2008-01-29 14:22:06 UTC (rev 5701)
@@ -48,7 +48,7 @@
 	private static final String HIDDEN_SUFFIX = "valueKeeper";
 	private static final String FUNCTION_ADD_TO_SELECTED = "myfaces_picklist_addToSelected";
     private static final String FUNCTION_REMOVE_FROM_SELECTED = "myfaces_picklist_removeFromSelected";
-    protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS = PickListControlsHelper.HELPERS;
+    protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS = ListShuttleControlsHelper.HELPERS;
     protected final static String SHOW_LABELS_ATTRIBUTE_NAME = "showButtonLabels";
     private static final String MESSAGE_BUNDLE_NAME = OrderingListRendererBase.class.getPackage().getName() + "ListShuttle";
     
@@ -158,201 +158,6 @@
 	    }
 	
 	}
-	/*protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-
-		 UIPickList picklist = (UIPickList) component;
-
-		 String availableListClientId = picklist.getClientId(context) + AVAILABLE_SUFFIX;
-		 String selectedListClientId = picklist.getClientId(context) + SELECTED_SUFFIX;
-		 String hiddenFieldCliendId = picklist.getClientId(context) + HIDDEN_SUFFIX;
-
-		 List <SelectItem> selectItemList = SelectUtils.getSelectItems(context,picklist);
-		 Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context, picklist);
-		 Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, picklist, context, converter);
-		 List selectItemsForSelectedValues = selectItemsForSelectedList(context, picklist, selectItemList, converter, lookupSet);
-		 List selectItemsForAvailableList = selectItemsForAvailableList(context, picklist, selectItemList, selectItemsForSelectedValues, converter);
-
-		 writer.startElement("table", picklist);
-		 writer.writeAttribute(HTML.id_ATTRIBUTE, picklist.getClientId(context), null);
-		 writer.startElement(HTML.TR_ELEMENT, picklist);
-		 writer.startElement(HTML.td_ELEM, picklist);
-		 	 
-		 encodeSelect(context, picklist, availableListClientId, picklist.isDisabled(), picklist.getSize(), selectItemsForAvailableList, converter, writer);
-
-		 writer.endElement(HTML.td_ELEM);
-
-		 // encode buttons
-		 writer.startElement(HTML.td_ELEM, picklist);
-
-		 String javascriptAddToSelected = FUNCTION_ADD_TO_SELECTED + "('"
-		                                  + availableListClientId + "','" + selectedListClientId + "','"
-		                                  + hiddenFieldCliendId + "')";
-		 String javascriptRemoveFromSelected = FUNCTION_REMOVE_FROM_SELECTED
-		                                       + "('" + availableListClientId + "','" + selectedListClientId
-		                                       + "','" + hiddenFieldCliendId + "')";
-
-		 encodeSwapButton(context, picklist, javascriptAddToSelected,true,writer);
-
-		 writer.startElement("br", picklist);
-		 writer.endElement("br");
-
-		 encodeSwapButton(context, picklist, javascriptRemoveFromSelected, false, writer);
-
-		 writer.endElement(HTML.td_ELEM);
-
-		 // encode selected list
-		 writer.startElement(HTML.td_ELEM, picklist);
-		 encodeSelect(context, picklist, selectedListClientId, picklist.isDisabled(), picklist.getSize(),
-		           selectItemsForSelectedValues, converter, writer);
-
-		 // hidden field with the selected values
-		 encodeHiddenField(context, picklist, hiddenFieldCliendId, lookupSet,writer);
-
-		 writer.endElement(HTML.td_ELEM);
-		 writer.endElement(HTML.TR_ELEMENT);
-		 writer.endElement("table");
-	 }*/
-	 
-	 /*private void encodeSelect(FacesContext context, UIPickList picklist, String clientId, boolean disabled,
-      		int size, List selectItemsToDisplay, Converter converter, ResponseWriter writer) throws IOException {
-
-		writer.startElement("select", picklist);
-		writer.writeAttribute("id", clientId, "id");
-		writer.writeAttribute("name", clientId, null);
-		writer.writeAttribute("multiple", "true", null);
-		getUtils().encodePassThruWithExclusions(context, picklist,"size,id,dir,multiple,name,class,style,styleClass,disabled");
-		
-		 
-		String computeStyleClass = "rich-pick-list rich-pick-list-outputlist";
-	    
-		String outputStyle = (String)picklist.getAttributes().get("style");
-		String outputStyleClass = (String)picklist.getAttributes().get("styleClass");
-		
-		if (outputStyle != null) {
-			outputStyle = outputStyle.trim();
-			if(!outputStyle.endsWith(";")) {
-				outputStyle = outputStyle + ";";
-			}
-		}
-		
-		if(outputStyleClass != null) {
-			computeStyleClass = computeStyleClass + " " + outputStyleClass;
-		}
-		
-		if (picklist.isDisplayValueOnly()) {
-			String displayValueOnlyStyleClass = picklist.getDisplayValueOnlyStyleClass();
-			String displayValueOnlyStyle = picklist.getDisplayValueOnlyStyle(); 
-			
-			if (displayValueOnlyStyleClass != null) {
-				computeStyleClass = computeStyleClass != null ? computeStyleClass + " " 
-										+ displayValueOnlyStyleClass : computeStyleClass; 
-			}
-			
-			if (displayValueOnlyStyle != null) {
-				
-				displayValueOnlyStyle = displayValueOnlyStyle.trim();
-				if(!displayValueOnlyStyle.endsWith(";")) {
-					displayValueOnlyStyle = displayValueOnlyStyle + ";";
-				} 
-				
-				outputStyle = outputStyle != null ? outputStyle + " " + displayValueOnlyStyle : outputStyle; 
-			}
-		}
-		
-		if (disabled) {
-			String disabledStyleClass = (String)picklist.getAttributes().get("disabledStyleClass");
-			if (disabledStyleClass != null) {
-				computeStyleClass = computeStyleClass + " " + disabledStyleClass;
-			}
-			
-			String disabledStyle = (String)picklist.getAttributes().get("disabledStyle");
-			if (disabledStyle != null) {
-					outputStyle = outputStyle != null ? outputStyle + " " + disabledStyle : disabledStyle;   
-			}
-			writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
-			
-		} else {
-			String enabledStyleClass = (String)picklist.getAttributes().get("enabledStyleClass");
-			if (enabledStyleClass != null) {
-				computeStyleClass = computeStyleClass + " " + enabledStyleClass;
-			}
-			
-			String enabledStyle = (String)picklist.getAttributes().get("enabledStyle");
-			if(enabledStyle != null) {
-				outputStyle = outputStyle != null ? outputStyle + "; " + enabledStyle : enabledStyle;
-			}
-		}
-		
-		writer.writeAttribute("class", computeStyleClass, null);
-		writer.writeAttribute(HTML.style_ATTRIBUTE, outputStyle, null);
-		writer.writeAttribute(HTML.STYLE_CLASS_ATTR, outputStyleClass, null);
-
-		if (size == 0) {
-			writer.writeAttribute("size", Integer.toString(selectItemsToDisplay.size()), null);
-		} else {
-			writer.writeAttribute("size", Integer.toString(size), null);
-		}
-				
-		renderSelectOptions(context, picklist, converter, Collections.EMPTY_SET, selectItemsToDisplay);
-		writer.writeText("", null);
-		writer.endElement("select");
-	 }*/
-	 
-	/*public void renderSelectOptions(FacesContext context, UIComponent component, Converter converter, Set lookupSet,
-					List selectItemList) throws IOException {
-		ResponseWriter writer = context.getResponseWriter();
-		
-		for (Iterator it = selectItemList.iterator(); it.hasNext();) {
-			SelectItem selectItem = (SelectItem) it.next();
-		
-			if (selectItem instanceof SelectItemGroup) {
-				writer.startElement("optgroup", component);
-				writer.writeAttribute("label", selectItem.getLabel(), null);
-				SelectItem[] selectItems = ((SelectItemGroup) selectItem).getSelectItems();
-				renderSelectOptions(context, component, converter, lookupSet, Arrays.asList(selectItems));
-				writer.endElement("optgroup");
-			} else {
-				String itemStrValue = PickListUtils.getConvertedStringValue(context, component, converter, selectItem.getValue());
-				writer.write('\t');
-				writer.startElement("option", component);
-				
-				if (itemStrValue != null) {
-					writer.writeAttribute(HTML.value_ATTRIBUTE, itemStrValue, null);
-				}
-		
-				if (lookupSet.contains(itemStrValue)) {  //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
-					writer.writeAttribute("selected", "selected", null);
-				}
-		
-				boolean disabled = selectItem.isDisabled();
-				if (disabled) {
-					writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
-				}
-		
-				boolean componentDisabled = isTrue(component.getAttributes().get("disabled"));
-				String labelClass = null;
-				if (componentDisabled || disabled) {
-					labelClass = (String) component.getAttributes().get("disabledClass");
-				} else {
-					labelClass = (String) component.getAttributes().get("enabled");
-				}
-		
-				if (labelClass != null) {
-					writer.writeAttribute("class", labelClass, "labelClass");
-				}
-		
-				boolean escape = isTrue(component.getAttributes().get("escape"));
-					
-				if (escape) {
-					writer.writeText(selectItem.getLabel(), null);
-				} else {
-					writer.write(selectItem.getLabel());
-				}
-		
-				writer.endElement("option");
-			}
-		}
-	}*/
 	
 	private void encodeRows(FacesContext context, UIComponent component, boolean source) throws IOException {
 	    List <SelectItem> selectItemsList = SelectUtils.getSelectItems(context,component);
@@ -601,32 +406,17 @@
 	
 	public void encodePickListControlsFacets(FacesContext context, UIComponent component)
 		throws IOException {
-	String clientId = component.getClientId(context);
-
-	ResponseWriter writer = context.getResponseWriter();
-	
-	int divider = SHUTTLE_HELPERS.length / 2;
-	
-	for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
-	    	/*SelectionState state = (i < divider ? sourceSelectionState : targetSelectionState);
-		boolean enabled;
-		if (i <= 1 || i >= SHUTTLE_HELPERS.length - 2) {
-			enabled = state.isItemExist();
-		} else {
-			enabled = state.isSelected();
-		}
-		
-		if (i % 2 == 1) {
-			enabled = !enabled;
-		}*/
-		
-		if (SHUTTLE_HELPERS[i].isRendered(context, null)) {
-			//proper assumption about helpers ordering
-			encodeControlFacet(context, component, SHUTTLE_HELPERS[i], clientId, writer, true, 
-					"rich-list-shuttle-button", " rich-shuttle-control");
-		}
+        	String clientId = component.getClientId(context);
+        
+        	ResponseWriter writer = context.getResponseWriter();
+        	
+        	int divider = SHUTTLE_HELPERS.length / 2;
+        	
+        	for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
+        			encodeControlFacet(context, component, SHUTTLE_HELPERS[i], clientId, writer, true, 
+        					"rich-list-shuttle-button", " rich-shuttle-control");
+        	}
 	}
-	}
 	
 	protected void encodeControlFacet(FacesContext context,
 		UIComponent component, OrderingComponentRendererBase.ControlsHelper helper,

Modified: trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickList.js
===================================================================
--- trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickList.js	2008-01-29 14:14:23 UTC (rev 5700)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickList.js	2008-01-29 14:22:06 UTC (rev 5701)
@@ -13,8 +13,8 @@
 		},
 		
 		moveItemByClick : function($super, event, sourceComponent, targetComponent, layoutManager) {
+			this.saveState([this.sourceList.getEventTargetRow(event)], this.isAdd(sourceComponent));
 			$super(event, sourceComponent, targetComponent, layoutManager);
-			this.saveState([this.sourceList.getEventTargetRow(event)], this.isAdd(sourceComponent));
 		},
 		
 		saveState : function(items, isAdd) {

Modified: trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickListSI.js
===================================================================
--- trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickListSI.js	2008-01-29 14:14:23 UTC (rev 5700)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickListSI.js	2008-01-29 14:22:06 UTC (rev 5701)
@@ -3,6 +3,8 @@
 Richfaces.PickListSI = Class.create(Richfaces.SelectItem, {
 	initialize : function($super, label, id, node) {
 		$super(label, id, node);
+		this.selected = false;
+		this.active = false;
 	},
 	
 	saveState : function() {}	




More information about the richfaces-svn-commits mailing list