Author: vmolotkov
Date: 2007-11-08 15:18:10 -0500 (Thu, 08 Nov 2007)
New Revision: 3839
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
control list was added
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-08
20:01:59 UTC (rev 3838)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-08
20:18:10 UTC (rev 3839)
@@ -14,6 +14,7 @@
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.compiler.FacetElement;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
import org.richfaces.component.Column;
@@ -27,6 +28,30 @@
private final static String ITEM_SEPARATOR = ",";
+ private final static String FACET_TOP = "Top";
+
+ private final static String FACET_BOTTOM = "Bottom";
+
+ private final static String FACET_UP = "Up";
+
+ private final static String FACET_DOWN = "Down";
+
+ private final static String CONTROL_TYPE_LINK = "link";
+
+ private final static String CONTROL_TYPE_BUTTON = "button";
+
+ private final static String CONTROL_TYPE_NONE = "none";
+
+ private final static String ATTRIBUTE_CONTROLS_TYPE = "controlsType";
+
+ private final static String CONTROL_ID_UP = "_up";
+
+ private final static String CONTROL_ID_DOWN = "_down";
+
+ private final static String CONTROL_ID_TOP = "_top";
+
+ private final static String CONTROL_ID_BOTTOM = "_bottom";
+
protected Class getComponentClass() {
return UIOrderingList.class;
}
@@ -35,15 +60,6 @@
return true;
}
- public void encodeOrderingListStructure(FacesContext context, UIOrderingList
orderingList)
- throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- //encodeCaption(context, orderingList);
- encodeHeader(context, orderingList);
- //encodeFooter(context, orderingList);
-
- }
-
protected Iterator columnFacets(UIOrderingList orderingList, final String name){
return new FilterIterator(orderingList.columns(), new Predicate() {
@@ -59,6 +75,10 @@
}});
}
+ public void encodeCaption(FacesContext context, UIOrderingList orderingList) {
+
+ }
+
public void encodeHeader(FacesContext context, UIOrderingList orderingList)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
@@ -78,6 +98,52 @@
writer.endElement("thead");
}
+ public void encodeControlsList(FacesContext context, UIOrderingList orderingList)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.td_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button_layout", null);
+ encodeContolsFacets(context, orderingList, writer);
+ writer.endElement(HTML.td_ELEM);
+ }
+
+ protected void encodeContolsFacets(FacesContext context, UIOrderingList orderingList,
ResponseWriter writer)
+ throws IOException {
+ Map facets = orderingList.getFacets();
+ String clientId = orderingList.getClientId(context);
+ encodeControlFacet(context, orderingList, writer, (UIComponent) facets.get(FACET_TOP),
"rich-ordering-control-top", clientId.concat(CONTROL_ID_TOP));
+ encodeControlFacet(context, orderingList, writer, (UIComponent) facets.get(FACET_UP),
"rich-ordering-control-up", clientId.concat(CONTROL_ID_UP));
+ encodeControlFacet(context, orderingList, writer, (UIComponent) facets.get(FACET_DOWN),
"rich-ordering-control-down", clientId.concat(CONTROL_ID_DOWN));
+ encodeControlFacet(context, orderingList, writer, (UIComponent)
facets.get(FACET_BOTTOM), "rich-ordering-control-bottom",
clientId.concat(CONTROL_ID_BOTTOM));
+ }
+
+ protected void encodeControlFacet(FacesContext context, UIOrderingList orderingList,
ResponseWriter writer, UIComponent facet, String facetClass, String controlId)
+ throws IOException {
+ if (facet != null) {
+ String controlType = (String)
orderingList.getAttributes().get(ATTRIBUTE_CONTROLS_TYPE);
+ String htmlElem = null;
+ if (CONTROL_TYPE_BUTTON.equals(controlType)) {
+ htmlElem = HTML.BUTTON;
+ } else if (CONTROL_TYPE_LINK.equals(controlType)) {
+ htmlElem = HTML.a_ELEMENT;
+ } else if (CONTROL_TYPE_NONE.equals(controlType)) {
+ //TODO
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button", null);
+
+ writer.startElement(htmlElem, orderingList);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, facetClass, null);
+ //writer.writeAttribute(HTML.TYPE_ATTR, HTML.BUTTON, null);
+ renderChild(context, facet);
+ writer.endElement(htmlElem);
+
+ writer.endElement(HTML.DIV_ELEM);
+ }
+ }
+
protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator headers, String skinCellClass,
String headerClass, String facetName, String element)
@@ -108,7 +174,6 @@
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
-
ResponseWriter writer = context.getResponseWriter();
UIDataAdaptor table = holder.getTable();
String clientId = holder.getTable().getClientId(context);
@@ -130,9 +195,25 @@
writer.endElement(HTML.TR_ELEMENT);
}
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ /*public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ String clientId = component.getClientId(context);
+
+ writer.startElement(HTML.TR_ELEMENT, component);
+ writer.startElement(HTML.td_ELEM, component);
+ encodeCaption(context, (UIOrderingList) component);
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+
+ writer.startElement(HTML.TR_ELEMENT, component);
+ writer.startElement(HTML.td_ELEM, component);
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId.concat("headerBox"),
null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_list", null);
+
+
encodeRows(context, component);
- }
+ }*/
public void doDecode(FacesContext context, UIComponent component) {
UIOrderingList orderingList = (UIOrderingList) component;
Modified:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-08
20:01:59 UTC (rev 3838)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-08
20:18:10 UTC (rev 3839)
@@ -12,9 +12,9 @@
<h:styles>css/orderingList.xcss</h:styles>
<h:scripts>
- scripts/SelectItem.js,
- scripts/OrderingList.js,
+ scripts/SelectItem.js,
scripts/LayoutManager.js
+ scripts/OrderingList.js,
</h:scripts>
<f:clientId var="clientId"/>
@@ -40,45 +40,31 @@
<input id="#{clientId}valueKeeper" type="hidden"
name="#{clientId}" value="#{component.submittedValueAsString}"/>
<table id="#{clientId}table" cellpadding="0"
cellspacing="0" class="ol_body">
- <tr>
- <td>
- <div id="#{clientId}headerBox" class="ol_list">
- <div class="ol_list_header">
- <table id="#{clientId}internal_header_tab"
class="ol_internal_header_tab" cellpadding="0"
cellspacing="0">
- <f:call name="encodeOrderingListStructure"/>
- </table>
+ <tr>
+ <td>
+ <div id="#{clientId}headerBox" class="ol_list">
+ <div class="ol_list_header">
+ <table id="#{clientId}internal_header_tab"
class="ol_internal_header_tab" cellpadding="0"
cellspacing="0">
+ <f:call name="encodeHeader"/>
+ </table>
+ </div>
+ <div id="#{clientId}contentBox"
class="ol_list_content">
+ <table id="#{clientId}internal_tab"
class="ol_internal_tab" cellpadding="0" cellspacing="0">
+ <tbody id="#{clientId}tbody"><vcp:body>
+ <f:call name="encodeRows" /></vcp:body>
+ </tbody>
+ </table>
+ </div>
</div>
- <div id="#{clientId}contentBox" class="ol_list_content">
- <table id="#{clientId}internal_tab" class="ol_internal_tab"
cellpadding="0" cellspacing="0">
- <tbody id="#{clientId}tbody">
- <vcp:body>
- <f:call name="renderChildren" />
- </vcp:body>
- </tbody>
- </table>
- </div>
- </div>
- </td>
- </tr>
+ </td>
+ <td>
+ <f:call name="encodeControlsList"/>
+ </td>
+ </tr>
</table>
<f:clientId var="clientId"/>
- <a id="#{clientId}sortLabel" href="#">Header</a>
- <img src="#{spacer}" border="0" width="1"
height="1"/>
- <a id="#{clientId}up" href="#" >
- <img src="#{upIcon}" border="0" />
- </a>
- <img src="#{spacer}" border="0" width="1"
height="1"/>
- <a id="#{clientId}down" href="#" >
- <img src="#{downIcon}" border="0" />
- </a>
- <img src="#{spacer}" border="0" width="1"
height="1"/>
- <a id="#{clientId}first" href="#" >
- <img src="#{topIcon}" border="0" />
- </a>
- <img src="#{spacer}" border="0" width="1"
height="1"/>
- <a id="#{clientId}last" href="#" >
- <img src="#{bottomIcon}" border="0" />
- </a>
+ <a id="#{clientId}sortLabel" href="#">Header</a>
+
</div>
<f:clientId var="cId"/>
<script type="text/javascript">
@@ -90,9 +76,8 @@
}
document.body.onselectstart = function() {return false;};
document.body.className = "body";
- var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper','#{cId}up', '#{cId}down',
'#{cId}first', '#{cId}last', '#{cId}sortLabel');
-
function init() {
+ var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper','_up', '_down', '_top',
'_bottom', '#{cId}sortLabel');
var layoutManager = new LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
layoutManager.widthSynchronization();
}