Author: abelevich
Date: 2010-03-13 09:09:37 -0500 (Sat, 13 Mar 2010)
New Revision: 16574
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml
Log:
remove inline javascript, add encode id on DS controls
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-12
20:02:03 UTC (rev 16573)
+++
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-13
14:09:37 UTC (rev 16574)
@@ -195,6 +195,8 @@
start = 0;
}
+ String clientId = component.getClientId(context);
+
for (int i = start, size = start + pages; i < size; i++) {
boolean isCurrentPage = (i + 1 == currentPage);
@@ -219,13 +221,14 @@
out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital ds_current
"+styleClass, null);
} else {
out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital
"+styleClass, null);
-
+ /*
out.writeAttribute(HTML.ONMOUSEOVER_ATTRIBUTE,
"this.className='ds_digital ds_over'", null);
out.writeAttribute(HTML.ONMOUSEOUT_ATTRIBUTE,
"this.className='ds_digital'", null);
out.writeAttribute(HTML.ONMOUSEUP_ATTRIBUTE,
"this.className='ds_digital ds_over'", null);
out.writeAttribute(HTML.ONMOUSEDOWN_ATTRIBUTE,
"this.className='ds_digital ds_press'", null);
out.writeAttribute(HTML.ONCLICK_ATTRIBUTE, getOnClick(context, component,
Integer.toString(i + 1)), null);
+ */
}
if (null != style) {
@@ -233,45 +236,60 @@
}
String page = Integer.toString(i + 1);
+ String id = clientId+ "_ds_" + page;
+ out.writeAttribute(HTML.ID_ATTRIBUTE,id, null);
+ digital.put(id, page);
out.writeText(page, null);
- digital.put("ds_" + page, page);
+
out.endElement(HTML.SPAN_ELEM);
}
return digital;
}
- public Map<String, String> getControls(FacesContext context, UIComponent
component, ControlsState controlsState) {
+ public Map<String, Map<String,String>> getControls(FacesContext context,
UIComponent component, ControlsState controlsState) {
//will be refactored
- Map<String, String> controls = new HashMap<String, String>();
+ Map<String, Map<String, String>> controls = new HashMap<String,
Map<String,String>>();
+ Map<String, String> right = new HashMap<String, String>();
+ Map<String, String> left = new HashMap<String, String>();
+ String clientId = component.getClientId(context);
+
if(controlsState.getFirstRendered() && controlsState.getFirstEnabled())
{
- controls.put("ds_f", "first");
+
+ left.put(clientId + "_ds_f", "first");
}
if(controlsState.getFastRewindRendered()&&
controlsState.getFastRewindEnabled()) {
- controls.put("ds_fr", "fastRewind");
+ left.put(clientId + "_ds_fr", "fastRewind");
}
if(controlsState.getFastForwardRendered()&&
controlsState.getFastForwardEnabled()) {
- controls.put("ds_ff", "fastForward");
+ right.put(clientId + "_ds_ff", "fastForward");
}
if(controlsState.getLastRendered()&& controlsState.getLastEnabled()) {
- controls.put("ds_l", "last");
+ right.put(clientId + "_ds_l", "last");
}
+ if(!left.isEmpty()) {
+ controls.put("left", left);
+ }
+
+ if(!right.isEmpty()) {
+ controls.put("right", right);
+ }
return controls;
}
- public void buildScript(ResponseWriter writer, FacesContext context, UIComponent
component, Map buttons, Map controls) throws IOException {
+ public void buildScript(ResponseWriter writer, FacesContext context, UIComponent
component, Map buttons, Map digitals) throws IOException {
JSFunction function = new JSFunction("new RichFaces.ui.DataScroller");
function.addParameter(component.getClientId(context));
Map<String, Object> options = new HashMap<String, Object>();
options.put("buttons", buttons);
- options.put("controls", controls);
+ options.put("digitals", digitals);
function.addParameter(options);
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml
===================================================================
---
root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml 2010-03-12
20:02:03 UTC (rev 16573)
+++
root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml 2010-03-13
14:09:37 UTC (rev 16574)
@@ -20,12 +20,12 @@
<c:if test="#{controlsState.firstRendered}">
<c:choose>
<c:when test="#{controlsState.firstEnabled}">
- <span class="ds_button ds_left"
onmousedown="this.className='ds_button ds_left ds_over'"
onmouseup="this.className='ds_button ds_left'"
onmouseout="this.className='ds_button ds_left'"
onclick="#{getOnClick(facesContext, component, 'first')}">
+ <span id="#{clientId}_ds_f" class="ds_button ds_left" >
««
</span>
</c:when>
<c:otherwise>
- <span class="ds_button ds_left ds_disabled">
+ <span id="#{clientId}_ds_f" class="ds_button ds_left
ds_disabled">
««
</span>
</c:otherwise>
@@ -36,29 +36,29 @@
<c:if test="#{controlsState.fastRewindRendered}">
<c:choose>
<c:when test="#{controlsState.fastRewindEnabled}">
- <span class="ds_button ds_left"
onmousedown="this.className='ds_button ds_left ds_over'"
onmouseup="this.className='ds_button ds_left'"
onmouseout="this.className='ds_button ds_left'"
onclick="#{getOnClick(facesContext, component, 'fastRewind')}">
+ <span id="#{clientId}_ds_fr" class="ds_button ds_left">
«
</span>
</c:when>
<c:otherwise>
- <span class="ds_button ds_left ds_disabled">
+ <span id="#{clientId}_ds_fr" class="ds_button ds_left
ds_disabled">
«
</span>
</c:otherwise>
</c:choose>
</c:if>
- <cdk:object type="java.util.Map" name="buttons"
value="#{renderPager(responseWriter, facesContext, component)}" />
+ <cdk:object type="java.util.Map" name="digitals"
value="#{renderPager(responseWriter, facesContext, component)}" />
<c:if test="#{controlsState.fastForwardRendered}">
<c:choose>
<c:when test="#{controlsState.fastForwardEnabled}">
- <span class="ds_button ds_right"
onmousedown="this.className='ds_button ds_right ds_over'"
onmouseup="this.className='ds_button ds_right'"
onmouseout="this.className='ds_button ds_right'"
onclick="#{getOnClick(facesContext, component, 'fastForward')}">
+ <span id="#{clientId}_ds_ff" class="ds_button ds_right">
»
</span>
</c:when>
<c:otherwise>
- <span class="ds_button ds_right ds_disabled">
+ <span id="#{clientId}_ds_ff" class="ds_button ds_right
ds_disabled">
»
</span>
</c:otherwise>
@@ -68,12 +68,12 @@
<c:if test="#{controlsState.lastRendered}">
<c:choose>
<c:when test="#{controlsState.lastEnabled}">
- <span class="ds_button ds_right"
onmousedown="this.className='ds_button ds_right ds_over'"
onmouseup="this.className='ds_button ds_right'"
onmouseout="this.className='ds_button ds_right'"
onclick="#{getOnClick(facesContext, component, 'last')}">
+ <span id="#{clientId}_ds_l" class="ds_button ds_right">
»»
</span>
</c:when>
<c:otherwise>
- <span class="ds_button ds_right ds_disabled">
+ <span id="#{clientId}_ds_l" class="ds_button ds_right
ds_disabled">
»»
</span>
</c:otherwise>
@@ -81,10 +81,10 @@
</c:if>
</span>
- <cdk:object type="java.util.Map" name="controls"
value="#{getControls(facesContext, component, controlsState)}" />
+ <cdk:object type="java.util.Map" name="buttons"
value="#{getControls(facesContext, component, controlsState)}" />
<script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component,
buttons, controls);"/>
+ <cdk:call expression="buildScript(responseWriter, facesContext, component,
buttons, digitals);"/>
</script>
</cc:implementation>
</cdk:root>
\ No newline at end of file