JBoss Rich Faces SVN: r5695 - in trunk/sandbox/ui/pickList/src/main: java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-01-29 08:11:32 -0500 (Tue, 29 Jan 2008)
New Revision: 5695
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.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
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist_.js
Modified:
trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/css/picklist.xcss
Log:
pickList component
Modified: trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
===================================================================
--- trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-01-29 12:11:07 UTC (rev 5694)
+++ trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-01-29 13:11:32 UTC (rev 5695)
@@ -15,9 +15,9 @@
<description>
<![CDATA[ ]]>
</description>
- <renderer generate="false" override="false">
- <name>org.richfaces.PickList</name>
- <classname>org.richfaces.renderkit.PickListRenderer</classname>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.PickListRenderer</name>
+ <template>htmlPickList.jspx</template>
</renderer>
<tag>
@@ -69,6 +69,42 @@
<classname>java.lang.String</classname>
</property>
+ <property>
+ <name>listClass</name>
+ <classname>java.lang.String</classname>
+ <description>CSS class for a list</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>switchByClick</name>
+ <classname>boolean</classname>
+ <description>If "true", dragging between lists realized by click </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
+ <name>sourceListWidth</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines width of a source list
+ </description>
+ <defaultvalue>"140"</defaultvalue>
+ </property>
+ <property>
+ <name>targetListWidth</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines width of a target list
+ </description>
+ <defaultvalue>"140"</defaultvalue>
+ </property>
+ <property>
+ <name>listsHeight</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines height of the list
+ </description>
+ <defaultvalue>"140"</defaultvalue>
+ </property>
&ui_component_attributes;
&html_universal_attributes;
&html_events;
Modified: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java 2008-01-29 12:11:07 UTC (rev 5694)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java 2008-01-29 13:11:32 UTC (rev 5695)
@@ -1,9 +1,17 @@
package org.richfaces.component;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
import javax.faces.component.UISelectMany;
+import javax.faces.context.FacesContext;
public abstract class UIPickList extends UISelectMany{
+ private String listClass;
+ private String moveControlsVerticalAlign;
+ public abstract String getMoveControlsVerticalAlign();
+ public abstract void setMoveControlsVerticalAlign(String moveControlsVerticalAlign);
+
public abstract boolean isDisplayValueOnly();
public abstract void setDisplayValueOnly(boolean displayValueOnly);
@@ -19,4 +27,43 @@
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
+ public abstract boolean isFastOrderControlsVisible();
+ public abstract void setFastOrderControlsVisible(boolean visible);
+
+ /**
+ * Get base clietntId of this component ( withowt iteration part )
+ *
+ * @param faces
+ * @return
+ */
+ public String getBaseClientId(FacesContext faces) {
+ // Return any previously cached client identifier
+ if (_baseClientId == null) {
+
+ // Search for an ancestor that is a naming container
+ UIComponent ancestorContainer = this;
+ StringBuffer parentIds = new StringBuffer();
+ while (null != (ancestorContainer = ancestorContainer.getParent())) {
+ if (ancestorContainer instanceof NamingContainer) {
+ parentIds.append(ancestorContainer.getClientId(faces))
+ .append(NamingContainer.SEPARATOR_CHAR);
+ break;
+ }
+ }
+ String id = getId();
+ if (null != id) {
+ _baseClientId = parentIds.append(id).toString();
+ } else {
+ _baseClientId = parentIds.append(
+ faces.getViewRoot().createUniqueId()).toString();
+ }
+ }
+ return (_baseClientId);
+
+ }
+ private String _baseClientId = null;
+ public abstract String getListClass();
+
+ public abstract void setListClass(String listClass);
+
}
Added: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java 2008-01-29 13:11:32 UTC (rev 5695)
@@ -0,0 +1,147 @@
+package org.richfaces.renderkit;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIListShuttle;
+import org.richfaces.component.UIOrderingBaseComponent;
+import org.richfaces.renderkit.html.images.ListShuttleIconCopy;
+import org.richfaces.renderkit.html.images.ListShuttleIconCopyAll;
+import org.richfaces.renderkit.html.images.ListShuttleIconCopyAllDisabled;
+import org.richfaces.renderkit.html.images.ListShuttleIconCopyDisabled;
+import org.richfaces.renderkit.html.images.ListShuttleIconRemove;
+import org.richfaces.renderkit.html.images.ListShuttleIconRemoveAll;
+import org.richfaces.renderkit.html.images.ListShuttleIconRemoveAllDisabled;
+import org.richfaces.renderkit.html.images.ListShuttleIconRemoveDisabled;
+
+public class PickListControlsHelper {
+
+ private final static String FACET_COPY_ALL = "copyAllControl";
+
+ private final static String FACET_REMOVE_ALL = "removeAllControl";
+
+ private final static String FACET_COPY = "copyControl";
+
+ private final static String FACET_REMOVE = "removeControl";
+
+ private final static String FACET_DIS_COPY_ALL = FACET_COPY_ALL + "Disabled";
+
+ private final static String FACET_DIS_REMOVE_ALL = FACET_REMOVE_ALL + "Disabled";
+
+ private final static String FACET_DIS_COPY = FACET_COPY + "Disabled";
+
+ private final static String FACET_DIS_REMOVE = FACET_REMOVE + "Disabled";
+
+ public final static String FACET_CAPTION = "caption";
+
+ private final static String ATTRIBUTE_CE_ONCOPYALLCLICK = "oncopyallclick";
+
+ private final static String ATTRIBUTE_CE_ONREMOVECLICK = "onremoveclick";
+
+ private final static String ATTRIBUTE_CE_ONCOPYCLICK = "oncopyclick";
+
+ private final static String ATTRIBUTE_CE_ONREMOVEALLCLICK = "onremoveallclick";
+
+ public final static String ATTRIBUTE_SOURCE_CAPTION_LABEL = "sourceCaptionLabel";
+
+ public final static String ATTRIBUTE_TARGET_CAPTION_LABEL = "targetCaptionLabel";
+
+ private final static String ATTRIBUTE_CLASS_COPY_ALL_CONTROL = FACET_COPY_ALL + "Class";
+
+ private final static String ATTRIBUTE_CLASS_REMOVE_ALL_CONTROL = FACET_REMOVE_ALL + "Class";
+
+ private final static String ATTRIBUTE_CLASS_REMOVE_CONTROL = FACET_REMOVE + "Class";
+
+ private final static String ATTRIBUTE_CLASS_COPY_CONTROL = FACET_COPY + "Class";
+
+ private final static String ATTRIBUTE_CLASS_DISABLED_CONTROL = "disabledControlClass";
+
+ private final static String DIS_CONTROL_ID_PREFIX = "dis";
+
+ private final static String CONTROL_ID_COPY_ALL = "copyAll";
+
+ private final static String CONTROL_ID_COPY = "copy";
+
+ private final static String CONTROL_ID_REMOVE = "remove";
+
+ private final static String CONTROL_ID_REMOVE_ALL = "removeAll";
+
+ private final static String DEFAULT_LABEL_COPY_ALL = "Copy all";
+ private final static String DEFAULT_LABEL_COPY = "Copy";
+ private final static String DEFAULT_LABEL_REMOVE = "Remove";
+ private final static String DEFAULT_LABEL_REMOVE_ALL = "Remove All";
+
+ protected static final OrderingComponentRendererBase.ControlsHelper[] HELPERS = new OrderingComponentRendererBase.ControlsHelper[] {
+ new OrderingComponentRendererBase.ControlsHelper("copyAll", "COPY_ALL_LABEL", DEFAULT_LABEL_COPY_ALL, ListShuttleIconCopyAll.class.getName(), FACET_COPY_ALL,
+ "-copyall", ATTRIBUTE_CLASS_COPY_ALL_CONTROL, "",
+ CONTROL_ID_COPY_ALL, ATTRIBUTE_CE_ONCOPYALLCLICK, true, "copyAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledCopyAll", "COPY_ALL_LABEL", DEFAULT_LABEL_COPY_ALL, ListShuttleIconCopyAllDisabled.class.getName(), FACET_DIS_COPY_ALL,
+ "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY_ALL), null, false, "copyAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("copy", "COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopy.class.getName(), FACET_COPY,
+ "-copy", ATTRIBUTE_CLASS_COPY_CONTROL, "",
+ CONTROL_ID_COPY, ATTRIBUTE_CE_ONCOPYCLICK ,true, "copy".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledCopy", "COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopyDisabled.class.getName(), FACET_DIS_COPY,
+ "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY), null, false, "copy".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("remove", "REMOVE_LABEL", DEFAULT_LABEL_REMOVE, ListShuttleIconRemove.class.getName(), FACET_REMOVE,
+ "-remove", ATTRIBUTE_CLASS_REMOVE_CONTROL, "",
+ CONTROL_ID_REMOVE, ATTRIBUTE_CE_ONREMOVECLICK, true, "remove".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledRemove", "REMOVE_LABEL", DEFAULT_LABEL_REMOVE, ListShuttleIconRemoveDisabled.class.getName(), FACET_DIS_REMOVE,
+ "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE), null, false, "remove".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("removeAll", "REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL, ListShuttleIconRemoveAll.class.getName(), FACET_REMOVE_ALL,
+ "-removeall", ATTRIBUTE_CLASS_REMOVE_ALL_CONTROL, "",
+ CONTROL_ID_REMOVE_ALL, ATTRIBUTE_CE_ONREMOVEALLCLICK, true, "removeAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledRemoveAll", "REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL, ListShuttleIconRemoveAllDisabled.class.getName(), FACET_DIS_REMOVE_ALL,
+ "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE_ALL), null, false, "removeAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX)) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return true;
+ }
+
+ }
+ };
+}
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 12:11:07 UTC (rev 5694)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-01-29 13:11:32 UTC (rev 5695)
@@ -3,16 +3,22 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import java.util.Set;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectMany;
import javax.faces.component.UISelectOne;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
@@ -20,31 +26,32 @@
import javax.faces.model.SelectItem;
import javax.faces.model.SelectItemGroup;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptString;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.util.SelectUtils;
import org.apache.commons.collections.CollectionUtils;
+import org.richfaces.component.UIListShuttle;
+import org.richfaces.component.UIOrderingBaseComponent;
import org.richfaces.component.UIPickList;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.picklist.util.PickListUtils;
+import org.richfaces.renderkit.OrderingComponentRendererBase.SelectionState;
public class PickListRenderer extends HeaderResourcesRendererBase {
private static final String AVAILABLE_SUFFIX = "_AVAILABLE";
private static final String SELECTED_SUFFIX = "_SELECTED";
- private static final String HIDDEN_SUFFIX = "_HIDDEN";
+ 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";
- private final InternetResource[] scripts = {getResource("/org/richfaces/renderkit/html/scripts/picklist.js")};
- private final InternetResource[] styles = {getResource("/org/richfaces/renderkit/html/css/picklist.xcss")};
-
- protected InternetResource[] getScripts() {
- return scripts;
- }
+ protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS = PickListControlsHelper.HELPERS;
+ protected final static String SHOW_LABELS_ATTRIBUTE_NAME = "showButtonLabels";
+ private static final String MESSAGE_BUNDLE_NAME = OrderingListRendererBase.class.getPackage().getName() + "ListShuttle";
- protected InternetResource[] getStyles() {
- return styles;
- }
protected List selectItemsForSelectedList(FacesContext facesContext,UIComponent uiComponent, List selectItemList, Converter converter, Set lookupSet) {
List selectItemForSelectedValues = new ArrayList(lookupSet.size());
for (Iterator i = selectItemList.iterator(); i.hasNext();) {
@@ -68,6 +75,14 @@
return SelectUtils.getSelectItems(context, component);
}
+ private final String bundleName;
+
+ public PickListRenderer() {
+ super();
+
+ this.bundleName = MESSAGE_BUNDLE_NAME;
+ }
+
public void decode(FacesContext context, UIComponent component) {
UIPickList picklist = (UIPickList)component;
@@ -83,6 +98,13 @@
return;
}
+ /*String[] valuesInline = getSubmittedValues(context, component);
+ if (valuesInline == null || (valuesInline[0] == null) || "".equals(valuesInline[0].trim())) {
+ ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
+ } else {
+ String[] reqValues = valuesInline[0].split(",");
+ ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
+ }*/
if (paramValuesMap.containsKey(hiddenClientId)) {
String[] valuesInline = (String[]) paramValuesMap.get(hiddenClientId);
@@ -97,6 +119,21 @@
}
}
+ private String[] getSubmittedValues(FacesContext context, UIComponent component) {
+ UIListShuttle listShuttle = (UIListShuttle) component;
+
+ String clientId = listShuttle.getBaseClientId(context);
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestParameterMap = externalContext.getRequestParameterMap();
+
+ String[] strings = null;
+
+ if (requestParameterMap.containsKey(clientId)) {
+ strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
+ }
+ return strings;
+ }
+
private boolean isDisabledOrReadOnly(UIPickList picklist) {
return picklist.isDisplayValueOnly() || isTrue(picklist.getAttributes().get("disabled"));
}
@@ -121,8 +158,7 @@
}
}
- @Override
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ /*protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
UIPickList picklist = (UIPickList) component;
@@ -175,9 +211,9 @@
writer.endElement(HTML.td_ELEM);
writer.endElement(HTML.TR_ELEMENT);
writer.endElement("table");
- }
+ }*/
- private void encodeSelect(FacesContext context, UIPickList picklist, String clientId, boolean disabled,
+ /*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);
@@ -260,9 +296,9 @@
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,
+ /*public void renderSelectOptions(FacesContext context, UIComponent component, Converter converter, Set lookupSet,
List selectItemList) throws IOException {
ResponseWriter writer = context.getResponseWriter();
@@ -316,8 +352,145 @@
writer.endElement("option");
}
}
+ }*/
+
+ private void encodeRows(FacesContext context, UIComponent component, boolean source) throws IOException {
+ List <SelectItem> selectItemsList = SelectUtils.getSelectItems(context,component);
+ Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context, component);
+ Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, component, context, converter);
+ List selectItemsForSelectedValues = selectItemsForSelectedList(context, component, selectItemsList, converter, lookupSet); //TODO: optimaze
+ List selectItemsForAvailableList = selectItemsForAvailableList(context, component, selectItemsList, selectItemsForSelectedValues, converter);
+
+ List selectItemList = null;
+ if (source) {
+ selectItemList = selectItemsForAvailableList;
+ } else {
+ selectItemList = selectItemsForSelectedValues;
+ }
+
+ int i = 0;
+ for (Iterator it = selectItemList.iterator(); it.hasNext();) {
+ i++;
+ SelectItem selectItem = (SelectItem) it.next();
+ if (selectItem instanceof SelectItemGroup) {
+ //TODO
+ } else {
+ String itemStrValue = PickListUtils.getConvertedStringValue(context, component, converter, selectItem.getValue());
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, component);
+ String clientId = component.getClientId(context);
+ String id = clientId + ":" + i;
+ writer.writeAttribute("id", id, null);
+
+ StringBuffer rowClassName = new StringBuffer();
+ StringBuffer cellClassName = new StringBuffer();
+ if (source) {
+ rowClassName.append("rich-shuttle-source-row");
+ cellClassName.append("rich-shuttle-source-cell");
+ } else {
+ rowClassName.append("rich-shuttle-target-row");
+ cellClassName.append("rich-shuttle-target-cell");
+ }
+
+ /*
+ * String rowClass = holder.getRowClass();
+ if (rowClass != null) {
+ rowClassName.append(' ');
+ rowClassName.append(rowClass);
+ }
+ */
+
+ /*
+ * boolean active = itemState.isActive();
+ boolean selected = itemState.isSelected();
+ selectionState.addState(selected);
+ if (selected) {
+ if (source) {
+ rowClassName.append(" rich-shuttle-source-row-selected");
+ cellClassName.append(" rich-shuttle-source-cell-selected");
+ } else {
+ rowClassName.append(" rich-shuttle-target-row-selected");
+ cellClassName.append(" rich-shuttle-target-cell-selected");
+ }
+ }
+ */
+ writer.writeAttribute("class", rowClassName.toString(), null);
+
+ writer.startElement(HTML.td_ELEM, component);
+ Object width = component.getAttributes().get("width");
+ if (width != null) {
+ writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
+ }
+ /*
+ * String columnClass = holder.getColumnClass(colCounter);
+ if (columnClass != null) {
+ writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
+ } else {
+ writer.writeAttribute("class", cellClassName.toString(), null);
+ }
+ */
+ encodeSpacer(context, component, writer);
+
+ boolean escape = isTrue(component.getAttributes().get("escape"));
+ if (escape) {
+ writer.writeText(selectItem.getLabel(), null);
+ } else {
+ writer.write(selectItem.getLabel());
+ }
+
+ encodeItemValue(context, component, writer, id, itemStrValue, lookupSet, i);
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+ }
}
+ public void encodeTargetRows(FacesContext context, UIComponent component) throws IOException {
+ encodeRows(context, component, false);
+ }
+
+ public void encodeSourceRows(FacesContext context, UIComponent component) throws IOException {
+ encodeRows(context, component, true);
+ }
+
+ private void encodeItemValue(FacesContext context, UIComponent component,
+ ResponseWriter writer, String id,
+ String itemStrValue, Set lookupSet, int rowKey) throws IOException { //rowKey = i
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
+
+ StringBuffer value = new StringBuffer();
+ //if (lookupSet.contains(itemStrValue)) {
+ //value.append('s');
+ //}
+
+ /*if (active) {
+ value.append('a');
+ }*/
+
+ //value.append(rowKey);
+ //value.append(':');
+ //value.append(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
+ value.append(itemStrValue); //??
+
+ writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
+
+ writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
+
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+ protected void encodeSpacer(FacesContext context, UIComponent component,
+ ResponseWriter writer) throws IOException {
+ writer.startElement(HTML.IMG_ELEMENT, component);
+ writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
+ writer.endElement(HTML.IMG_ELEMENT);
+ }
+
private void encodeSwapButton(FacesContext context, UIComponent component, String javaScriptFunction,
boolean isRight,ResponseWriter writer) throws IOException {
@@ -353,6 +526,14 @@
writer.endElement(HTML.BUTTON);
}
+ public void encodeHiddenField(FacesContext context, UIComponent component) throws IOException {
+ UIPickList pl = (UIPickList) component;
+ ResponseWriter writer = context.getResponseWriter();
+ Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context, pl);
+ Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, (UIPickList) pl, context, converter);
+ encodeHiddenField(context, pl, pl.getClientId(context) + HIDDEN_SUFFIX, lookupSet, writer);
+ }
+
private void encodeHiddenField(FacesContext context, UIComponent component,
String hiddenFieldCliendId, Set lookupSet, ResponseWriter writer) throws IOException {
@@ -380,4 +561,215 @@
protected Class<? extends UIComponent> getComponentClass() {
return UIPickList.class;
}
+
+ public String getAsEventHandler(FacesContext context, UIComponent component, String attributeName) {
+ String event = (String) component.getAttributes().get(attributeName);
+ ScriptString result = JSReference.NULL;
+
+ if (event != null) {
+ event = event.trim();
+
+ if (event.length() != 0) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("event");
+ function.addToBody(event);
+
+ result = function;
+ }
+ }
+
+ return ScriptUtils.toScript(result);
+ }
+
+ public String getColumnClassesAsJSArray(FacesContext context, UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component, "columnClasses"));
+ }
+
+ public String getRowClassesAsJSArray(FacesContext context, UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component, "rowClasses"));
+ }
+
+ protected List getClassesAsList(FacesContext context, UIComponent component, String attr) {
+
+ String value = (String) ((UIComponent) component).getAttributes().get(attr);
+ if (value != null && (value.length() != 0)) {
+ return Arrays.asList(value.split(","));
+ }
+ return null;
+ }
+
+ 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");
+ }
+ }
+ }
+
+ protected void encodeControlFacet(FacesContext context,
+ UIComponent component, OrderingComponentRendererBase.ControlsHelper helper,
+ String clientId, ResponseWriter writer, boolean enabled, String baseStyle,
+ String baseControlStyle) throws IOException {
+ Locale locale = null;
+
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ }
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceBundle bundle = null;
+
+ if (locale != null) {
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, locale, contextClassLoader);
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
+ Map attributes = component.getAttributes();
+ UIComponent facet = component.getFacet(helper.getFacetName());
+ boolean useFacet = (facet != null && facet.isRendered());
+
+ renderDefaultControl(context, component, writer, useFacet,
+ helper, clientId, bundle ,enabled, baseStyle, baseControlStyle);
+ }
+
+ protected void renderDefaultControl(FacesContext context,
+ UIComponent orderingList, ResponseWriter writer,
+ boolean useFacet, OrderingComponentRendererBase.ControlsHelper helper, String clientId, ResourceBundle bundle,
+ boolean enabled, String baseStyle, String baseControlStyle)
+ throws IOException {
+ UIComponent facet = orderingList.getFacet(helper.getFacetName());
+ String customEvent = null;
+ Map attributes = orderingList.getAttributes();
+ if (helper.customEvent != null) {
+ customEvent = (String) attributes.get(helper.customEvent);
+ }
+
+ String styleFromAttribute = (String) attributes
+ .get(helper.styleFromAttribute);
+
+ String baseStyleLight = baseStyle.concat("-light");
+ String baseStylePress = baseStyle.concat("-press");
+
+ String currentStyle = baseControlStyle + helper.getStyleClassName();
+ if (styleFromAttribute != null) {
+ currentStyle = styleFromAttribute.concat(currentStyle);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ String controlId = clientId + helper.getIdSuffix();
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); //FIXME:
+ writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
+ String style = null;
+ if (enabled) {
+ style = "display:block;";
+ } else {
+ style = "display:none;";
+ }
+ writer.writeAttribute(HTML.style_ATTRIBUTE, style, null);
+ if (!useFacet) {
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + helper.getButtonStyleClass(), null);
+ if (helper.enable) {
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, "this.className='" + baseStyleLight + "'", null);
+ writer.writeAttribute(HTML.onmousedown_ATTRIBUTE, "this.className='" + baseStylePress + "'", null);
+ writer.writeAttribute(HTML.onmouseup_ATTRIBUTE, "this.className='" + baseStyle + "'", null);
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, "this.className='" + baseStyle + "'", null);
+ }
+
+ writer.startElement(HTML.a_ELEMENT, orderingList);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link", null); //FIXME:
+ writer.writeAttribute(HTML.HREF_ATTR, "#", null);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;", null);
+ if (!helper.enable) {
+ writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-a-disabled", null);
+ writer.startElement(HTML.a_ELEMENT, orderingList);
+ } else {
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection", null);
+ writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Control.onblur(this);", null);
+ writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Control.onfocus(this);", null);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content", null);
+
+ }
+
+ if (customEvent != null) {
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent,null);
+ }
+
+ if (useFacet) {
+ renderChild(context, facet);
+ } else {
+ writer.startElement(HTML.IMG_ELEMENT, orderingList);
+ writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.border_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, helper.getFacetName(),
+ null);
+ writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
+ helper.getImageURI()).getUri(context, null), null);
+
+ writer.endElement(HTML.IMG_ELEMENT);
+
+ if (getUtils().isBooleanAttribute(orderingList, SHOW_LABELS_ATTRIBUTE_NAME)) {
+ String label = (String) attributes.get(helper.getLabelAttributeName());
+
+ if (label == null && bundle != null) {
+ try {
+ label = bundle.getString(helper.getBundlePropertyName());
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
+ if (label == null) {
+ label = helper.getDefaultText();
+ }
+
+ writer.writeText(label, null);
+ }
+ }
+ // writer.writeAttribute(HTML.id_ATTRIBUTE, clientId +
+ // helper.getIdSuffix(), null);
+
+ // writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
+
+ if (!useFacet) {
+ writer.endElement(HTML.DIV_ELEM);
+ if (!helper.enable) {
+ writer.endElement(HTML.a_ELEMENT);
+ }
+ writer.endElement(HTML.a_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+}
}
Modified: trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/css/picklist.xcss
===================================================================
--- trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/css/picklist.xcss 2008-01-29 12:11:07 UTC (rev 5694)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/css/picklist.xcss 2008-01-29 13:11:32 UTC (rev 5695)
@@ -2,99 +2,290 @@
<f:template xmlns:f='http:/jsf.exadel.com/template'
xmlns:u='http:/jsf.exadel.com/template/util'
xmlns="http://www.w3.org/1999/xhtml" >
- <f:verbatim>
- <![CDATA[
-
- .rich-pick-list{
- font-family : Arial;
- font-size :11px;
- width : 200px;
- height : 150px;
- border : 1px solid;
- }
-
- .rich-pick-button{
- background : top left repeat-x;
- cursor : pointer;
- font-family : Arial;
- font-size :11px;
- border : 1px solid;
- padding : 0px 0px 0px 0px;
- margin : 3px;
- }
-
- .rich-pick-button-light{
- background : top left repeat-x;
- cursor : pointer;
- font-family : Arial;
- font-size :11px;
- border : 1px solid;
- padding : 0px 0px 0px 0px;
- margin : 3px;
- }
-
- .rich-pick-button-press{
- background : top left repeat-x;
- cursor : pointer;
- font-family : Arial;
- font-size :11px;
- border : 1px solid;
- padding : 0px 0px 0px 0px;
- margin : 3px;
- }
- ]]>
- </f:verbatim>
+
+<f:verbatim><![CDATA[
+
+.rich-shuttle-controls {
+ padding : 0px 8px 5px 8px;
+}
+
+.rich-shuttle-list-content {
+ overflow: auto;
+}
+
+.rich-shuttle-list-header {
+ overflow: hidden;
+}
+
+.rich-shuttle-header-tab-cell, .rich-shuttle-header-tab-cell-last {
+ padding : 2px;
+ border-style: solid;
+ font-weight: normal;
+ white-space: nowrap;
+ background-repeat: repeat-x;
+ border-top: 0px;
+ border-left: 0px;
+}
+
+.rich-shuttle-internal-tab {
+ width:100%;
+}
+
+.body {
+ -moz-user-select: none;
+}
+]]>
+</f:verbatim>
+
+<u:selector name=".rich-shuttle-list">
+ <u:style name="background-color" skin="tableBackgroundColor"/>
+ <u:style name="border-width" value="0px" />
+ <u:style name="border-style" value="none" />
+</u:selector>
+
+<u:selector name=".rich-shuttle-source-cell, .rich-shuttle-target-cell, .rich-shuttle-source-cell *, .rich-shuttle-target-cell *">
+ <u:style name="color" skin="generalTextColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ <u:style name="white-space" value="nowrap"/>
+</u:selector>
+
+<f:verbatim><![CDATA[
+
+.rich-shuttle-control-disabled, .rich-shuttle-control-top, .rich-shuttle-control-bottom,
+.rich-shuttle-control-up, .rich-shuttle-control-down, .rich-shuttle-control-copyall,
+.rich-shuttle-control-copy, .rich-shuttle-control-remove, .rich-shuttle-control-removeall {
+ border : 1px solid;
+ margin-bottom : 3px;
+}
+
+.rich-list-shuttle-button, .rich-list-shuttle-button-disabled {
+ background : top left repeat-x;
+ padding : 2px;
+}
+
+.rich-list-shuttle-button {
+ cursor : pointer;
+}
+
+.rich-list-shuttle-button-light {
+ background : top left repeat-x;
+ border-style: solid;
+ cursor : pointer;
+ padding: 1px;
+}
+
+.rich-list-shuttle-button-press {
+ background : top left repeat-x;
+ border-style: solid;
+ padding : 2px 0px 0px 2px;
+}
+
+.rich-list-shuttle-button-valign {
+ vertical-align : middle;
+}
+
+.rich-list-shuttle-button-layout {
+ padding : 15px 8px 15px 0px;
+}
+
+.rich-list-shuttle-button-content {
+ padding : 0px 4px 0px 1px;
+ text-align : left;
+ white-space: nowrap;
+}
+
+.rich-list-shuttle-button-content img {
+ margin-right: 2px;
+ vertical-align: middle;
+}
+
+a.rich-list-shuttle-button-selection:visited,
+a.rich-list-shuttle-button-selection:link {
+ color: inherit;
+}
+
+.rich-list-shuttle-button-a-disabled {
+ cursor: default;
+ text-decoration: none;
+}
+
+.rich-list-shuttle-caption {
+ text-align: left;
+ padding : 1px;
+}
+
+.rich-shuttle-source-caption {
+ padding: 3px 3px 3px 8px;
+}
+
+.rich-shuttle-target-caption {
+ padding: 3px 3px 3px 0px;
+}
+
+.rich-shuttle-source-items {
+ margin: 0px 0px 8px 8px;
+}
+
+.rich-shuttle-target-items {
+ margin: 0px 0px 8px 0px;
+}
+
+.rich-shuttle-source-row-active, .rich-shuttle-target-row-active {
+ background : transparent none repeat-x scroll left top;
+}
+
+.rich-shuttle-source-row-selected, .rich-shuttle-target-row-selected {
+ background : transparent none repeat-x scroll left top;
+}
+
+.rich-shuttle-source-cell, .rich-shuttle-target-cell {
+ padding : 2px;
+ white-space: nowrap;
+ border: 0px;
+}
+
+.rich-shuttle-source-cell-selected, .rich-shuttle-target-cell-selected {
+ padding : 2px;
+ white-space: nowrap;
+}
+
+.rich-shuttle-source-cell-active, .rich-shuttle-target-cell-active {
+ padding: 1px 2px;
+ white-space: nowrap;
+ border-top: 1px dotted;
+ border-bottom: 1px dotted;
+}
+
+]]>
+</f:verbatim>
+
+ <u:selector name=".rich-list-shuttle">
+ <!--u:style name="background-color" skin="additionalBackgroundColor" />
+ <u:style name="border-color" skin="tableBorderColor" />
+ <u:style name="border-width" skin="tableBorderWidth" />
+ <u:style name="border-style" value="solid" /-->
+ <u:style name="-moz-user-select" value="-moz-none" />
+ </u:selector>
+
+ <u:selector name=".rich-shuttle-header-tab-cell, .rich-shuttle-header-tab-cell-last">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.gradientimages.OrderingListHeaderGradient" />
+ </u:style>
+ <u:style name="background-color" skin="tabBackgroundColor" />
+ <u:style name="color" skin="generalTextColor" />
+ <u:style name="font-family" skin="headerFamilyFont" />
+ <u:style name="font-size" skin="headerSizeFont" />
+
+ <u:style name="border-right-width" skin="tableBorderWidth" />
+ <u:style name="border-bottom-width" skin="tableBorderWidth" />
+
+ <u:style name="border-right-color" skin="tableBorderColor" />
+ <u:style name="border-bottom-color" skin="tableBorderColor" />
+ </u:selector>
- <u:selector name=".rich-pick-list">
- <u:style name="background" skin="tableBackgroundColor" />
+ <u:selector name=".rich-shuttle-header-tab-cell-last">
+ <u:style name="border-right-width" value="0px" />
+ </u:selector>
+
+<u:selector name=".rich-list-shuttle-button">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.gradientimages.OrderingListButtonGradient" />
+ </u:style>
+ <u:style name="background-color" skin="tabBackgroundColor" />
+ <u:style name="color" skin="generalTextColor"/>
+ <u:style name="font-family" skin="headerFamilyFont"/>
+ <u:style name="font-size" skin="headerSizeFont"/>
+</u:selector>
+
+<u:selector name=".rich-list-shuttle-button-disabled">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.gradientimages.OrderingListButtonGradient" />
+ </u:style>
+ <u:style name="background-color" skin="tabBackgroundColor" />
+ <u:style name="color" skin="tabDisabledTextColor"/>
+ <u:style name="font-family" skin="headerFamilyFont"/>
+ <u:style name="font-size" skin="headerSizeFont"/>
+</u:selector>
+
+ <u:selector name=".rich-list-shuttle-button-light">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.gradientimages.OrderingListButtonGradient" />
+ </u:style>
+ <u:style name="background-color" skin="tabBackgroundColor" />
+ <u:style name="border-color" skin="selectControlColor" />
+ <u:style name="border-width" skin="tableBorderWidth" />
+ <u:style name="font-family" skin="headerFamilyFont" />
+ <u:style name="font-size" skin="headerSizeFont" />
+ <u:style name="color" skin="generalTextColor"/>
+ </u:selector>
+
+ <u:selector name=".rich-list-shuttle-button-press">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.gradientimages.OrderingListClickedGradient" />
+ </u:style>
+ <u:style name="background-color" skin="tabBackgroundColor" />
<u:style name="border-color" skin="tableBorderColor" />
+ <u:style name="border-width" skin="tableBorderWidth" />
+ <u:style name="font-family" skin="headerFamilyFont" />
+ <u:style name="font-size" skin="headerSizeFont" />
+ <u:style name="color" skin="generalTextColor"/>
</u:selector>
+
+ <u:selector name=".rich-shuttle-source-cell-last, .rich-shuttle-target-cell-last">
+ <u:style name="border-right-color" skin="selectControlColor" />
+ </u:selector>
- <u:selector name=".rich-pick-button">
- <u:style name="background-color" skin="trimColor" />
+ <u:selector name=".rich-shuttle-source-items, .rich-shuttle-target-items">
+ <u:style name="background-color" skin="generalBackgroundColor" />
<u:style name="border-color" skin="tableBorderColor" />
+ <u:style name="border-width" skin="tableBorderWidth" />
+ <u:style name="border-style" value="solid" />
</u:selector>
- <u:selector name=".rich-pick-button-light">
- <u:style name="background-color" skin="trimColor" />
- <u:style name="border-color" skin="selectControlColor" />
+ <u:selector name=".rich-shuttle-source-cell-selected, .rich-shuttle-target-cell-selected, .rich-shuttle-source-cell-selected *, .rich-shuttle-target-cell-selected *">
+ <u:style name="color" skin="generalTextColor"/>
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
</u:selector>
- <u:selector name=".rich-pick-button-press">
- <u:style name="background-color" skin="additionalBackgroundColor" />
- <u:style name="border-color" skin="selectControlColor" />
+ <u:selector name=".rich-shuttle-source-cell-active, .rich-shuttle-target-cell-active, .rich-shuttle-source-cell-active *, .rich-shuttle-target-cell-active *">
+ <u:style name="font-size" skin="generalSizeFont" />
+ <u:style name="font-family" skin="generalFamilyFont" />
</u:selector>
+ <u:selector name=".rich-shuttle-source-cell-active, .rich-shuttle-target-cell-active" >
+ <u:style name="border-top-color" skin="generalTextColor" />
+ <u:style name="border-bottom-color" skin="generalTextColor" />
+ </u:selector>
+ <u:selector name=".rich-shuttle-control-disabled, .rich-shuttle-control-top, .rich-shuttle-control-bottom, .rich-shuttle-control-up, .rich-shuttle-control-down, .rich-shuttle-control-copyall, .rich-shuttle-control-copy, .rich-shuttle-control-remove, .rich-shuttle-control-removeall">
+ <u:style name="border-color" skin="tableBorderColor" />
+ </u:selector>
- <u:selector name=".rich-pick-right-arrow">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.images.PickListRightArrowImage" />
- </u:style>
+ <u:selector name=".rich-list-shuttle-button-content">
+ <u:style name="font-family" skin="headerFamilyFont" />
+ <u:style name="font-size" skin="headerSizeFont" />
</u:selector>
- <u:selector name=".rich-pick-left-arrow">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.images.PickListLeftArrowImage" />
- </u:style>
+ <u:selector name=".rich-list-shuttle-button-selection">
+ <u:style name="color" skin="generalTextColor" />
+ <u:style name="text-decoration" value="none" />
+ <u:style name="display" value="block" />
</u:selector>
- <u:selector name=".rich-pick-button-light">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.images.PickListButtonLightGradient" />
- </u:style>
+ <u:selector name="a.rich-list-shuttle-button-a-disabled a">
+ <u:style name="color" skin="tabDisabledTextColor"/>
</u:selector>
- <u:selector name=".rich-pick-button">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.images.PickListButtonGradient" />
- </u:style>
+ <u:selector name=".rich-shuttle-source-caption, .rich-shuttle-target-caption">
+ <u:style name="font-family" skin="headerFamilyFont" />
+ <u:style name="font-size" skin="headerSizeFont" />
+ <u:style name="font-weight" skin="headerWeightFont" />
</u:selector>
- <u:selector name=".rich-pick-button-press">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.images.PickListButtonPressGradient" />
- </u:style>
+ <u:selector name=".rich-shuttle-source-row-selected, .rich-shuttle-target-row-selected">
+ <u:style name="background-color" skin="additionalBackgroundColor" />
</u:selector>
-
-
-</f:template>
\ No newline at end of file
+}
+
+</f:template>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickList.js 2008-01-29 13:11:32 UTC (rev 5695)
@@ -0,0 +1,105 @@
+if(!window.Richfaces) window.Richfaces = {};
+
+Richfaces.PickList = Class.create(Richfaces.ListShuttle, {
+ initialize : function($super, targetList, sourceList, clientId, controlIds, switchByClick, sourceLayoutManager, targetLayoutManager, onlistchanged, valueKeeperId) {
+ $super(targetList, sourceList, clientId, controlIds, switchByClick, sourceLayoutManager, targetLayoutManager, onlistchanged);
+ this.valueKeeper = $(valueKeeperId);
+ this.controlListManager();
+ },
+
+ moveItems : function($super, sourceComponent, targetComponent, items) {
+ this.saveState(items, this.isAdd(sourceComponent));
+ $super(sourceComponent, targetComponent, items);
+ },
+
+ moveItemByClick : function($super, event, sourceComponent, targetComponent, layoutManager) {
+ $super(event, sourceComponent, targetComponent, layoutManager);
+ this.saveState([this.sourceList.getEventTargetRow(event)], this.isAdd(sourceComponent));
+ },
+
+ saveState : function(items, isAdd) {
+ var items = this.getSIAsLabels(items);
+ if (isAdd) {
+ var valuesAsString = this.valueKeeper.value;
+ if (valuesAsString.length != 0) {
+ valuesAsString += ",";
+ }
+ this.valueKeeper.value = valuesAsString + items.join(",");
+ } else {
+ var values = this.valueKeeper.value.split(",");
+ for (var i = 0; i < items.length; i++) {
+ values.remove(items[i]);
+ }
+ values.without(items);
+ this.valueKeeper.value = values.join(",");
+ }
+ },
+
+ isAdd : function(sourceComponent) {
+ if (this.targetList.shuttleTable.id == sourceComponent.shuttleTable.id) {
+ return false;
+ }
+ return true;
+ },
+
+ getSIAsLabels : function(items) {
+ if ((items == null) || (items.length == 0)) {
+ return;
+ }
+ var result = new Array();
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+ if (!item.input) {
+ item = item.item;
+ }
+ result[i] = item.input.value;
+ }
+ return result;
+ }
+});
+
+Richfaces.PickList.Source = Class.create(Richfaces.ListBase);
+Richfaces.PickList.Target = Class.create(Richfaces.ListBase);
+
+Richfaces.PickList.Source.SelectItem = Class.create(Richfaces.PickListSI);
+Richfaces.PickList.Source.SelectItem.prototype.CLASSES = {
+ ROW : {
+ ACTIVE : "rich-shuttle-source-row-active",
+ SELECTED : "rich-shuttle-source-row-selected",
+ DISABLED : "rich-shuttle-source-row-disabled",
+ NORMAL : "rich-shuttle-source-row"
+ },
+ CELL : {
+ ACTIVE : "rich-shuttle-source-cell-active",
+ SELECTED : "rich-shuttle-source-cell-selected",
+ DISABLED : "rich-shuttle-source-cell-disabled",
+ NORMAL : "rich-shuttle-source-cell",
+ BEGIN: " rich-shuttle-source-cell-first",
+ END: " rich-shuttle-source-cell-last"
+ }
+};
+
+Richfaces.PickList.Target.SelectItem = Class.create(Richfaces.PickListSI);
+Richfaces.PickList.Target.SelectItem.prototype.CLASSES = {
+ ROW : {
+ ACTIVE : "rich-shuttle-target-row-active",
+ SELECTED : "rich-shuttle-target-row-selected",
+ DISABLED : "rich-shuttle-target-row-disabled",
+ NORMAL : "rich-shuttle-target-row"
+ },
+ CELL : {
+ ACTIVE : "rich-shuttle-target-cell-active",
+ SELECTED : "rich-shuttle-target-cell-selected",
+ DISABLED : "rich-shuttle-target-cell-disabled",
+ NORMAL : "rich-shuttle-target-cell",
+ BEGIN: " rich-shuttle-target-cell-first",
+ END: " rich-shuttle-target-cell-last"
+ }
+};
+
+Richfaces.PickList.HANDLERS = {
+ copy: function (e) { this.moveItems(this.sourceList, this.targetList, this.sourceList.selectedItems); return false; },
+ copyAll: function (e) { this.moveItems(this.sourceList, this.targetList, this.sourceList.shuttleItems); return false; },
+ remove: function (e) { this.moveItems(this.targetList, this.sourceList, this.targetList.selectedItems); return false; },
+ removeAll: function (e) { this.moveItems(this.targetList, this.sourceList, this.targetList.shuttleItems); return false; }
+};
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/PickListSI.js 2008-01-29 13:11:32 UTC (rev 5695)
@@ -0,0 +1,9 @@
+if (!window.Richfaces) { window.Richfaces = {}; }
+
+Richfaces.PickListSI = Class.create(Richfaces.SelectItem, {
+ initialize : function($super, label, id, node) {
+ $super(label, id, node);
+ },
+
+ saveState : function() {}
+});
\ No newline at end of file
Copied: trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist_.js (from rev 5298, 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 (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist_.js 2008-01-29 13:11:32 UTC (rev 5695)
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ /**
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+// moves an item to the selected list
+function myfaces_picklist_addToSelected(availableListId, selectedListId, hiddenId)
+{
+ var availableList = document.getElementById(availableListId);
+ var selectedList = document.getElementById(selectedListId);
+
+ myfaces_picklist_move(availableList, selectedList, hiddenId);
+ myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
+// removes an item from the selected list
+function myfaces_picklist_removeFromSelected(availableListId, selectedListId, hiddenId)
+{
+ var availableList = document.getElementById(availableListId);
+ var selectedList = document.getElementById(selectedListId);
+
+ myfaces_picklist_move(selectedList, availableList, hiddenId);
+ myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
+function myfaces_picklist_move(fromList, toList, hiddenId) {
+ // Return, if no items selected
+ var selectedIndex = fromList.selectedIndex;
+ if(selectedIndex < 0) { return; }
+
+ // Decremental loop, so the index is not affected in the moves
+ for(var i = fromList.length - 1; i >= 0; i--) {
+ if(fromList.options.item(i).selected) {
+ toList.appendChild(fromList.options.item(i));
+ }
+ }
+
+}
+
+// Selection - invoked on submit
+function myfaces_picklist_updateHidden(selectedList, hiddenId) {
+ var hiddenField = document.getElementById(hiddenId);
+
+ var arrValues = new Array(selectedList.options.length);
+ for (var i = 0; i<selectedList.options.length; i++) {
+ arrValues[i] = selectedList.options[i].value;
+ }
+
+ hiddenField.value = arrValues.join();
+}
\ No newline at end of file
16 years, 11 months
JBoss Rich Faces SVN: r5694 - in trunk/sandbox/ui/progressBAR/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-01-29 07:11:07 -0500 (Tue, 29 Jan 2008)
New Revision: 5694
Modified:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
Log:
refactoring
Modified: trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-01-29 12:08:51 UTC (rev 5693)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-01-29 12:11:07 UTC (rev 5694)
@@ -6,7 +6,24 @@
package org.richfaces.component;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.servlet.http.HttpServletRequest;
+
import org.ajax4jsf.component.UIPoll;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.context.AjaxContextImpl;
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.javascript.JSLiteral;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.renderkit.AbstractProgressBarRenderer;
/**
* TODO Class description goes here.
@@ -15,12 +32,161 @@
*
*/
-//TODO add @since declaration
+// TODO add @since declaration
public abstract class UIProgressBar extends UIPoll {
public static final String COMPONENT_TYPE = "org.richfaces.ProgressBar";
public static final String COMPONENT_FAMILY = "org.richfaces.ProgressBar";
-
- //TODO value can be any number, e.g. big decimal
+
+ /** Request parameter name containing component state to render */
+ private static final String FORCE_STATE_PARAM = "forceState";
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // TODO Auto-generated method stub
+ if (event instanceof AjaxEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ AjaxContext ajaxContext = AjaxContextImpl
+ .getCurrentInstance(facesContext);
+
+ HttpServletRequest request = (HttpServletRequest) facesContext
+ .getExternalContext().getRequest();
+
+ Number percent = getNumber(this.getAttributes().get("value"));
+ Number maxValue = getNumber(this.getAttributes().get("maxValue"));
+ Map params = request.getParameterMap();
+ if (params.containsKey(FORCE_STATE_PARAM)) {
+ ajaxContext.addComponentToAjaxRender(this);
+ String[] str = (String[]) params.get(FORCE_STATE_PARAM);
+ for (String s : str) {
+ this.getAttributes().put(FORCE_STATE_PARAM, s);
+ }
+ } else if (percent.doubleValue() < maxValue.doubleValue()
+ && params.containsKey("percent")) {
+ ajaxContext.removeRenderedArea(this.getClientId(facesContext));
+ ajaxContext.setResponseData(getResponseData(percent,
+ facesContext));
+ Object rerenderAfterComplete = this.getAttributes().get(
+ "reRender");
+ Set ajaxRegions = AjaxRendererUtils
+ .asSet(rerenderAfterComplete);
+
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ ajaxContext.addComponentToAjaxRender(this, id);
+ }
+ }
+ } else {
+ ajaxContext.addComponentToAjaxRender(this);
+ }
+
+ }
+ }
+
+ /**
+ * Returns ajax response data
+ *
+ * @param uiComponent
+ * @param percent
+ * @return
+ */
+ private Map<Object, Object> getResponseData(Number percent,
+ FacesContext facesContext) {
+
+ AbstractProgressBarRenderer renderer = (AbstractProgressBarRenderer) this
+ .getRenderer(facesContext);
+
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ map.put("percent", percent);
+ map.put("interval", this.getInterval());
+
+ if (this.getAttributes().get("style") != null) {
+ map.put("style", this.getAttributes().get("style"));
+ }
+
+ boolean enabled = (Boolean) this.getAttributes().get("enabled");
+ map.put("enabled", Boolean.toString(enabled));
+
+ map.put("markup", getMarkup(facesContext, renderer));
+
+ map.put("context", getContext(renderer, percent));
+
+ addStyles2Responce(map, "completeClass", this.getAttributes().get(
+ "completeClass"));
+ addStyles2Responce(map, "remainClass", this.getAttributes().get(
+ "remainClass"));
+ addStyles2Responce(map, "styleClass", this.getAttributes().get(
+ "styleClass"));
+ return map;
+
+ }
+
+ private Map<String, Object> getContext(
+ AbstractProgressBarRenderer renderer, Number percent) {
+ Map<String, Object> context = renderer.getParametersMap(this);
+ if (context == null) {
+ context = new HashMap<String, Object>();
+ }
+ context.put("value", percent.toString());
+ context.put("maxValue", this.getAttributes().get("maxValue"));
+ context.put("minValue", this.getAttributes().get("minValue"));
+ return context;
+ }
+
+ private JSLiteral getMarkup(FacesContext context,
+ AbstractProgressBarRenderer renderer) {
+ JSLiteral literal = null;
+ try {
+ literal = new JSLiteral(renderer.getMarkup(context, this)
+ .toString());
+ } catch (Exception e) {
+
+ }
+ return literal;
+ }
+
+ /**
+ * Add component classes to ajax response
+ *
+ * @param buffer
+ * @param attr
+ * @param newValue
+ */
+ private void addStyles2Responce(Map<Object, Object> map, String key,
+ Object className) {
+ if (className != null) {
+ map.put(key, className);
+ }
+ }
+
+ /**
+ * Converts value attr to number value
+ *
+ * @param v -
+ * value attr
+ * @return result
+ */
+ public Number getNumber(Object v) {
+ Number result = new Integer(0);
+ if (v != null) {
+ try {
+ if (v instanceof String) {
+ result = Double.parseDouble((String) v);
+ } else {
+ Number n = (Number) v;
+ if (n instanceof BigDecimal || n instanceof Double
+ || n instanceof Float) {
+ result = n.floatValue();
+ } else if (n instanceof Integer) {
+ result = n.intValue();
+ }
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+ return result;
+ }
+
}
Modified: trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java 2008-01-29 12:08:51 UTC (rev 5693)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java 2008-01-29 12:11:07 UTC (rev 5694)
@@ -15,13 +15,15 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.FactoryFinder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletRequest;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.context.AjaxContextImpl;
+import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
@@ -30,6 +32,7 @@
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.CountingOutputWriter;
import org.richfaces.component.UIProgressBar;
/**
@@ -61,47 +64,12 @@
*/
@Override
protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
- AjaxContext ajaxContext = AjaxContextImpl
- .getCurrentInstance(facesContext);
-
- if (!ajaxContext.isAjaxRequest()) {
- return;
- }
-
- HttpServletRequest request = (HttpServletRequest) facesContext
- .getExternalContext().getRequest();
-
- Number percent = getNumber(uiComponent.getAttributes().get("value"));
- Number maxValue = getNumber(uiComponent.getAttributes().get("maxValue"));
- Map params = request.getParameterMap();
- if (params.containsKey(FORCE_STATE_PARAM)) {
- ajaxContext.addComponentToAjaxRender(uiComponent);
- String[] str = (String[]) params.get(FORCE_STATE_PARAM);
- for (String s : str) {
- uiComponent.getAttributes().put(FORCE_STATE_PARAM, s);
- }
- } else if (percent.doubleValue() < maxValue.doubleValue()
- && params.containsKey("percent")) {
- ajaxContext.removeRenderedArea(uiComponent
- .getClientId(facesContext));
- ajaxContext.setResponseData(getResponseData(uiComponent, percent));
- Object rerenderAfterComplete = uiComponent.getAttributes().get(
- "reRender");
- Set ajaxRegions = AjaxRendererUtils.asSet(rerenderAfterComplete);
-
- if (ajaxRegions != null) {
- for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
- String id = iter.next().toString();
- ajaxContext.addComponentToAjaxRender(uiComponent, id);
- }
- }
- } else {
- ajaxContext.addComponentToAjaxRender(uiComponent);
- }
+ new AjaxEvent(uiComponent).queue();
}
/**
* Render progress state forced from javascript
+ *
* @param state
* @param context
* @param component
@@ -121,6 +89,7 @@
/**
* Gets state forced from javascript
+ *
* @param component
* @return
*/
@@ -131,72 +100,46 @@
return null;
}
+
/**
- * Returns ajax response data
- * @param uiComponent
- * @param percent
+ * Renderes label markup
+ * @param context
+ * @param component
* @return
*/
- private String getResponseData(UIComponent uiComponent, Number percent) {
- UIProgressBar progressBar = (UIProgressBar) uiComponent;
- StringBuffer buffer = new StringBuffer();
- buffer.append("percent:");
- buffer.append(percent);
- buffer.append(",");
+ public StringBuffer getMarkup(FacesContext context, UIComponent component) {
+ StringBuffer result = null;
+ CountingOutputWriter customWriter = new CountingOutputWriter();
+ ResponseWriter writer = context.getResponseWriter();
+ try {
- buffer.append("interval:");
- buffer.append(progressBar.getInterval());
- buffer.append(",");
-
- if (progressBar.getAttributes().get("style") != null) {
- buffer.append("style:");
- buffer.append(progressBar.getAttributes().get("style"));
- buffer.append(",");
+ String defaultRenderKitId = context.getApplication()
+ .getDefaultRenderKitId();
+ if (null == defaultRenderKitId) {
+ defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = renderKitFactory.getRenderKit(context,
+ defaultRenderKitId);
+
+ ResponseWriter responseWriter = renderKit.createResponseWriter(
+ customWriter, null, "UTF-8");
+ context.setResponseWriter(responseWriter);
+ writeScriptBody(context, component, true);
+ result = customWriter.getContent();
+ if (writer != null) {
+ context.setResponseWriter(writer);
+ }
+ } catch (Exception e) {
+ e.getMessage();
}
- boolean enabled = (Boolean) uiComponent.getAttributes().get("enabled");
- buffer.append("enabled:");
- buffer.append(Boolean.toString(enabled));
- buffer.append(",");
+ return result;
- addStyles2Responce(buffer, "completeClass", (String) uiComponent
- .getAttributes().get("completeClass"));
- addStyles2Responce(buffer, "remainClass", (String) uiComponent
- .getAttributes().get("remainClass"));
- addStyles2Responce(buffer, "styleClass", (String) uiComponent
- .getAttributes().get("styleClass"));
- return buffer.toString();
-
}
/**
- * Add component classes to ajax response
- *
- * @param buffer
- * @param attr
- * @param newValue
- */
- private void addStyles2Responce(StringBuffer buffer, String attr,
- String newValue) {
- if (newValue != null) {
- buffer.append(attr);
- buffer.append(":");
- buffer.append(newValue);
- buffer.append(",");
- }
- }
-
- /**
- * Return poll function name
- *
- * @param component
- * @return
- */
- public String getVarName(UIComponent component) {
- return String.valueOf(Math.abs(component.hashCode()));
- }
-
- /**
* Methods encodes AJAX script for polling
*
* @param context -
@@ -249,8 +192,10 @@
StringBuffer script = new StringBuffer();
writer.startElement(HTML.SPAN_ELEM, component);
writer.startElement(HTML.SCRIPT_ELEM, component);
- script.append("new ProgressBar('" + component.getClientId(context)
- + "').renderLabel();\n");
+ script.append(
+ "new ProgressBar('" + component.getClientId(context)
+ + "').renderLabel(").append(
+ getMarkup(context, component)).append(",null);\n");
writer.append(script.toString());
writer.endElement(HTML.SCRIPT_ELEM);
writer.endElement(HTML.SPAN_ELEM);
@@ -268,7 +213,7 @@
throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIProgressBar progressBar = (UIProgressBar) component;
- AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(context);
+
writer.startElement(HTML.SPAN_ELEM, component);
writer.startElement(HTML.SCRIPT_ELEM, component);
@@ -286,23 +231,20 @@
.append("','").append(containerId).append("','").append(formId)
.append("','").append(mode).append("',").append(minValue)
.append(",").append(maxValue).append(",");
- writer.write(script.toString());
- writeScriptBody(context, component, true);
- script = new StringBuffer();
- script.append(",");
script.append(ScriptUtils.toScript(getParametersMap(component)));
script.append(",");
script.append(ScriptUtils.toScript(buildAjaxOptions(clientId,
progressBar, context)));
- String progressVar = (String)component.getAttributes().get("progressVar");
+ String progressVar = (String) component.getAttributes().get(
+ "progressVar");
if (progressVar != null) {
script.append(",'");
script.append(progressVar);
script.append("'");
- }else {
+ } else {
script.append(",null");
}
-
+
script.append(");\n");
writer.write(script.toString());
@@ -360,13 +302,6 @@
functionDefinition.addParameter("event");
functionDefinition.addParameter("data");
StringBuffer body = new StringBuffer();
- ComponentVariables variables = ComponentsVariableResolver.getVariables(
- this, component);
- UIComponent nestingContainer = (UIComponent) AjaxRendererUtils
- .findAjaxContainer(context, component);
- UIComponent form = (UIComponent) AjaxRendererUtils
- .getNestingForm(component);
- String content = (String) variables.getVariable("content");
body.append("new ProgressBar('" + clientId + "').onComplete(data);");
functionDefinition.addToBody(body.toString());
@@ -496,11 +431,11 @@
* @param component
* @return
*/
- private Map<String, String> getParametersMap(UIComponent component) {
+ public Map<String, Object> getParametersMap(UIComponent component) {
String parameters = (String) component.getAttributes()
.get("parameters");
if (parameters != null) {
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, Object> map = new HashMap<String, Object>();
String[] strs = parameters.split(SPLIT_EXPRS);
if (strs != null) {
for (String str : strs) {
Modified: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-01-29 12:08:51 UTC (rev 5693)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-01-29 12:11:07 UTC (rev 5694)
@@ -8,14 +8,13 @@
this.id = id;
}
},
- init: function (id, containerId, formId, mode, minValue, maxValue, label , context, options, progressVar) {
+ init: function (id, containerId, formId, mode, minValue, maxValue, context, options, progressVar) {
ProgressBar.Pollers[id] = {};
ProgressBar.Pollers[id]['containerId'] = containerId;
ProgressBar.Pollers[id]['formId'] = formId;
ProgressBar.Pollers[id]['mode'] = mode;
ProgressBar.Pollers[id]['minValue'] = minValue;
ProgressBar.Pollers[id]['maxValue'] = maxValue;
- ProgressBar.Pollers[id]['label'] = label;
ProgressBar.Pollers[id]['context'] = context;
ProgressBar.Pollers[id]['options'] = options;
ProgressBar.Pollers[id]['progressVar'] = progressVar;
@@ -32,9 +31,8 @@
},
onComplete: function (data) {
if (data) {
- this.parseResponse(data);
- this.setValue(this.value);
- this.renderLabel();
+ this.updateComponent(data);
+ this.renderLabel(data['markup'], data['context']);
this.poll();
}
@@ -50,42 +48,30 @@
}
return placeholders;
},
- parseResponse: function (data) {
- var params = data.split(",");
- for (var i = 0; i < params.length; i++) {
- var param = params[i];
- if (param) {
- var t = param.split(":");
- if (t)
- if (t.length == 2) {
- var k = t[0];
- var v = t[1];
- this.updateComponent(k,v);
- }
- }
- }
- },
- updateComponent: function (k,v) {
- switch (k) {
- case "style" : this.updateStyle(v); break;
- case "percent" : this.value = v; break;
- case "enabled" : if (v == "false") { this.disable(); }; break;
- case "completeClass" : this.updateClassName($(this.id + ":complete"), v, "rich-progress-bar-base"); break;
- case "remainClass" : this.updateClassName($(this.id + ":remain"), v, "rich-progress-bar-base"); break;
- case "styleClass" : this.updateClassName($(this.id), v, "rich-progress-bar"); break;
- case "interval" : if (ProgressBar.Pollers[this.id]['options']['pollinterval'] != v) ProgressBar.Pollers[this.id]['options']['pollinterval'] = v; break;
+ updateComponent: function (data) {
+ this.updateStyle(data['style']);
+ this.setValue(data['percent']);
+ if (!data['enabled']) { this.disable(); }
+ this.updateClassName($(this.id + ":complete"), data['completeClass'], "rich-progress-bar-base");
+ this.updateClassName($(this.id + ":remain"), data['remainClass'], "rich-progress-bar-base");
+ this.updateClassName($(this.id), data['styleClass'], "rich-progress-bar-base");
+
+ if (ProgressBar.Pollers[this.id]['options']['pollinterval'] != data['interval']) {
+ ProgressBar.Pollers[this.id]['options']['pollinterval'] = data['interval'];
}
},
updateStyle: function (style) {
+ if (!style) { return; }
var d = $(this.id);
- if (d.style != style) {
- d.style = style;
+ if (d.style)
+ if (d.style.cssText != style) {
+ d.style.cssText = style;
d = $(this.id + ":remain");
- if (d) d.style = style;
+ if (d) d.style.cssText = style;
d = $(this.id + ":complete");
- if (d) d.style = style;
+ if (d) d.style.cssText = style;
d = $(this.id + ":upload");
- if (d) d.style = style;
+ if (d) d.style.cssText = style;
}
},
updateClassName: function (o, newName, defaultClass) {
@@ -106,9 +92,10 @@
}
return context;
},
- renderLabel: function () {
- var context = this.getContext();
- var markup = ProgressBar.Pollers[this.id]['label'];
+ renderLabel: function (markup, context) {
+ if (!context) {
+ context = this.getContext();
+ }
var html = markup.invoke('getContent', context).join('');
$(this.id + ":remain").innerHTML = $(this.id + ":complete").innerHTML = html;
},
@@ -138,12 +125,12 @@
return (this.getMode() == "ajax");
},
setValue: function (val) {
+ val = "" + val;
var p = val;
if (val != null) {
if (val.indexOf("%") < 0)
val = val + "%";
}
-
if ( parseFloat(p) < parseFloat(this.getMinValue())) {
if (!this.isAjaxMode()) {
this.forceState("initial",null);
16 years, 11 months
JBoss Rich Faces SVN: r5693 - trunk/framework/impl/src/main/java/org/ajax4jsf/resource.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-01-29 07:08:51 -0500 (Tue, 29 Jan 2008)
New Revision: 5693
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CountingOutputWriter.java
Log:
Fix write(int c) method
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CountingOutputWriter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CountingOutputWriter.java 2008-01-29 12:08:28 UTC (rev 5692)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CountingOutputWriter.java 2008-01-29 12:08:51 UTC (rev 5693)
@@ -73,7 +73,7 @@
* @param c - int to be written
*/
public void write(int c) throws IOException {
- buffer.append(c);
+ buffer.append(Character.toChars(c));
written += sizeOfInt;
}
16 years, 11 months
JBoss Rich Faces SVN: r5692 - trunk/framework/api/src/main/java/org/ajax4jsf/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-01-29 07:08:28 -0500 (Tue, 29 Jan 2008)
New Revision: 5692
Added:
trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
Log:
Add JSLiteral class
Added: trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java (rev 0)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2008-01-29 12:08:28 UTC (rev 5692)
@@ -0,0 +1,58 @@
+/*
+ * JSLiteral.java Date created: 29.01.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.javascript;
+
+/**
+ * Class provides creation of simple literal javascript to be set in ajax response data
+ * @author Andrey Markavtsov
+ *
+ */
+public class JSLiteral extends ScriptStringBase {
+
+ /** Javascript literal text */
+ private String literal;
+
+
+ /**
+ * Default constructor
+ */
+ public JSLiteral() {
+ super();
+ }
+
+ /**
+ * Constructor using literal parameter
+ * @param literal
+ */
+ public JSLiteral(String literal) {
+ super();
+ this.literal = literal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
+ */
+ public void appendScript(StringBuffer jsString) {
+ jsString.append(literal);
+
+ }
+
+ /**
+ * @return the literal
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /**
+ * @param literal the literal to set
+ */
+ public void setLiteral(String literal) {
+ this.literal = literal;
+ }
+
+}
16 years, 11 months
JBoss Rich Faces SVN: r5691 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: cluts
Date: 2008-01-29 05:45:50 -0500 (Tue, 29 Jan 2008)
New Revision: 5691
Added:
trunk/docs/userguide/en/src/main/resources/images/tooltip_CS2.png
Log:
http://jira.jboss.com/jira/browse/RF-1052 - added screens
Added: trunk/docs/userguide/en/src/main/resources/images/tooltip_CS2.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/tooltip_CS2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 11 months
JBoss Rich Faces SVN: r5690 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: cluts
Date: 2008-01-29 05:45:36 -0500 (Tue, 29 Jan 2008)
New Revision: 5690
Added:
trunk/docs/userguide/en/src/main/resources/images/tooltip_CS1.png
Log:
http://jira.jboss.com/jira/browse/RF-1052 - added screens
Added: trunk/docs/userguide/en/src/main/resources/images/tooltip_CS1.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/tooltip_CS1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 11 months
JBoss Rich Faces SVN: r5687 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: cluts
Date: 2008-01-29 05:44:22 -0500 (Tue, 29 Jan 2008)
New Revision: 5687
Modified:
trunk/docs/userguide/en/src/main/docbook/included/toolTip.xml
Log:
http://jira.jboss.com/jira/browse/RF-1052 - done for tooltip
Modified: trunk/docs/userguide/en/src/main/docbook/included/toolTip.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/toolTip.xml 2008-01-29 10:43:56 UTC (rev 5686)
+++ trunk/docs/userguide/en/src/main/docbook/included/toolTip.xml 2008-01-29 10:44:22 UTC (rev 5687)
@@ -316,7 +316,7 @@
<section>
<title>Definition of Custom Style Classes</title>
- <table>
+ <table id="tab_cn6">
<title>Classes names that define a component appearance</title>
<tgroup cols="2">
<thead>
@@ -338,16 +338,67 @@
It depends on <emphasis role="bold"><property><rich:toolTip></property></emphasis> layout what a wrapper element <emphasis><property><span></property></emphasis> or <emphasis><property><div></property></emphasis>to choose.
</para>
<para>In order to redefine styles for all <emphasis role="bold">
- <property><rich:toolTip></property>
- </emphasis> components on a page using CSS, it's enough to create class with the
- same name and define necessary properties in it.</para>
+ <property><rich:toolTipl></property>
+ </emphasis> components on a page using CSS, it's enough to create classes with the
+ same names (possible classes could be found in the table <link linkend="tab_cn6">above</link>) and define necessary properties in them. An example is placed below:</para>
- <para>To change styles of particular <emphasis role="bold">
- <property><rich:toolTip></property>
- </emphasis> components define your own style class in the corresponding <emphasis
- role="bold">
- <property><rich:toolTip></property>
- </emphasis>attributes</para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="CSS"><![CDATA[...
+.rich-tool-tip{
+ background-color: #ebf3fd;
+ border-color: White;
+ font-style: italic;
+}
+...]]></programlisting>
+
+ <para>This is a result:</para>
+
+ <figure>
+ <title>Redefinition styles with predefined classes</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/tooltip_CS1.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para>In the example a tool tip background color, border color and font style were changed.</para>
+ <para>Also it’s possible to change styles of particular <emphasis role="bold"
+ ><property><rich:toolTipl></property></emphasis> component. In this case you should create own style classes and use them in corresponding <emphasis role="bold"
+ ><property><rich:toolTip></property></emphasis> <property>styleClass</property> attributes. An example is placed below:</para>
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="CSS"><![CDATA[...
+.myClass{
+ background-color: #fffcd2;
+ border-color: #fdf7a2;
+}
+...]]></programlisting>
+ <para>The <emphasis><property>"styleClass"</property></emphasis> attribute for <emphasis role="bold"
+ ><property><rich:toolTip> </property></emphasis> is defined as it’s shown in the example below:</para>
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="CSS"><![CDATA[<rich:toolTip ... styleClass="myClass"/>
+]]></programlisting>
+
+ <para>This is a result:</para>
+
+ <figure>
+ <title>Redefinition styles with own classes and styleClass attributes</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/tooltip_CS2.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para>As it could be seen on the picture above, background color and border color of tool tip were changed.</para>
</section>
<section>
<title>Relevant Resources Links</title>
16 years, 11 months
JBoss Rich Faces SVN: r5686 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: cluts
Date: 2008-01-29 05:43:56 -0500 (Tue, 29 Jan 2008)
New Revision: 5686
Modified:
trunk/docs/userguide/en/src/main/docbook/included/tabPanel.xml
Log:
http://jira.jboss.com/jira/browse/RF-1052 - correct for tabpanel
Modified: trunk/docs/userguide/en/src/main/docbook/included/tabPanel.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/tabPanel.xml 2008-01-29 10:43:39 UTC (rev 5685)
+++ trunk/docs/userguide/en/src/main/docbook/included/tabPanel.xml 2008-01-29 10:43:56 UTC (rev 5686)
@@ -328,8 +328,7 @@
<emphasis role="bold">Example:</emphasis>
</para>
<programlisting role="CSS"><![CDATA[...
-.rich-tab-active{
- color: #FFA500;
+.rich-tabhdr-cell-active{
font-weight: bold;
}
...]]></programlisting>
@@ -349,7 +348,7 @@
<para>Also it’s possible to change styles of particular <emphasis role="bold"
><property><rich:tabPanel></property></emphasis> component. In this case you should create own style classes and use them in corresponding <emphasis role="bold"
- ><property><rich:tabPanel></property></emphasis> <emphasis><property>activeTabClass</property></emphasis> attributes. An example is placed below:</para>
+ ><property><rich:tabPanel></property></emphasis> <emphasis><property>styleClass</property></emphasis> attributes. An example is placed below:</para>
<para>
<emphasis role="bold">Example:</emphasis>
@@ -359,7 +358,7 @@
font-style: italic;
}
...]]></programlisting>
- <para>The <emphasis><property>"activeTabClass"</property></emphasis> attribute for <emphasis role="bold"
+ <para>The <emphasis><property>"styleClass"</property></emphasis> attribute for <emphasis role="bold"
><property><rich:tabPanel> </property></emphasis> is defined as it’s shown in the example below:</para>
<para>
@@ -371,7 +370,7 @@
<para>This is a result:</para>
<figure>
- <title>Redefinition styles with own classes and activeTabClass attributes</title>
+ <title>Redefinition styles with own classes and styleClass attributes</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/tabPanel_CS2.png"/>
16 years, 11 months