001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/jsf/renderer/PagerButtonControlRenderer.java $
003: * $Id: PagerButtonControlRenderer.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.jsf.renderer;
021:
022: import java.io.IOException;
023: import javax.faces.component.UIComponent;
024: import javax.faces.component.UIOutput;
025: import javax.faces.context.FacesContext;
026: import javax.faces.context.ResponseWriter;
027: import javax.faces.render.Renderer;
028:
029: /**
030: * <p>Description: </p>
031: * <p>Render a next/previous control for a pager attached to a dataTable.</p>
032: * <p>Copyright: Copyright (c) 2004</p>
033: * <p>Organization: Sakai Project</p>
034: * @author Ed Smiley
035: * @version $Id: PagerButtonControlRenderer.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
036: */
037:
038: public class PagerButtonControlRenderer extends Renderer {
039:
040: public boolean supportsComponentType(UIComponent component) {
041: return (component instanceof UIOutput);
042: }
043:
044: public void decode(FacesContext context, UIComponent component) {
045: }
046:
047: public void encodeChildren(FacesContext context,
048: UIComponent component) throws IOException {
049: ;
050: }
051:
052: public void encodeBegin(FacesContext context, UIComponent component)
053: throws IOException {
054: ;
055: }
056:
057: /*** GENERATOR FILE: ...pagerButtonControl.html some hand mods *** */
058:
059: /* *** IF SOURCE DOCUMENT CHANGES YOU NEED TO REGENERATE THIS METHOD*** */
060: /**
061: * <p>Faces render output method .</p>
062: * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
063: *
064: * @param context <code>FacesContext</code> for the current request
065: * @param component <code>UIComponent</code> being rendered
066: *
067: * @throws IOException if an input/output error occurs
068: */
069: public void encodeEnd(FacesContext context, UIComponent component)
070: throws IOException {
071:
072: ResponseWriter writer = context.getResponseWriter();
073: String formId = (String) component.getAttributes()
074: .get("formId");
075: String controlId = (String) component.getAttributes().get(
076: "controlId");
077:
078: // previous
079: writer.write("<div align=\"right\">");
080: writer
081: .write(" <input id=\""
082: + formId
083: + "_"
084: + controlId
085: + "_pager_button_control_previousbtn\" type=\"button\" name=\""
086: + formId
087: + "_"
088: + controlId
089: + "_pager_button_control_previousbtn\" value=\"Previous\"");
090: writer.write(" onclick=\"document.forms['" + formId + "']['"
091: + controlId + "'].value='<'; document.forms['" + formId
092: + "'].submit(); return false;\" />");
093:
094: // selct number per page: this is not functional yet
095: // writer.write("-->");
096: writer.write(" <select id=\"" + formId + "_" + controlId
097: + "_pager_button_control_selectlist\" name=\"" + formId
098: + "_" + controlId
099: + "_pager_button_control_selectlist\" size=\"1\">");
100: writer
101: .write(" <option value=\"10\" selected>Show 10 Items per Page</option>");
102: writer
103: .write(" <option value=\"20\">Show 20 Items per Page</option>");
104: writer
105: .write(" <option value=\"30\">Show 30 Items per Page</option>");
106: writer
107: .write(" <option value=\"50\">Show 50 Items per Page</option>");
108: writer
109: .write(" <option value=\"100\">Show 100 Items per Page</option>");
110: writer.write(" </select>");
111: // writer.write("<!--");
112:
113: // next
114: writer
115: .write(" <input id=\""
116: + formId
117: + "_"
118: + controlId
119: + "_pager_button_control_nextbtn\" type=\"button\" name=\""
120: + formId
121: + "_"
122: + controlId
123: + "_pager_button_control_nextbtn\" value=\"Next\"");
124: writer.write(" onclick=\"document.forms['" + formId + "']['"
125: + controlId + "'].value='>'; document.forms['" + formId
126: + "'].submit(); return false;\" />");
127: writer.write("</div>");
128: }
129:
130: }
|