This content has been marked as final.
Show 3 replies
-
1. Re: Richfaces CDK problem
ilya_shaikovsky Nov 21, 2008 4:17 AM (in response to lmckinney)Is there any more concise documentation on how to use the cdk properly (via pdf, word doc, etc) that I could obtain.
All the documents available for now is in the wiki and the guide you mentioned.
About your case - please add code snippets carefully and point to the problematic generated code. -
2. Re: Richfaces CDK problem
lmckinney Nov 21, 2008 10:12 AM (in response to lmckinney)Thank you for the quick response.
Here is my custom codepackage ca.whitewaterweb.renderkit; // // Imports // import java.util.Map; import javax.faces.component.UIComponent; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; import ca.whitewaterweb.component.UIEventCalendar; public abstract class EventCalendarRenderer extends HeaderResourcesRendererBase { //This is my custom code public static final String CURRENT_MONTH_VALUE = "monthValue"; public static final String CURRENT_YEAR_VALUE = "yearValue"; @Override public void decode(FacesContext context, UIComponent component) { // TODO Auto-generated method stub super.decode(context, component); //custom code example ExternalContext ext = context.getExternalContext(); Map<String,String> requestParms = ext.getRequestParameterMap(); UIEventCalendar cal = (UIEventCalendar) component; String clientId = cal.getClientId(context); String currentMonth = (String) requestParms.get(clientId + CURRENT_MONTH_VALUE); String currentYear = (String) requestParms.get(clientId + CURRENT_YEAR_VALUE); cal.setCurrentMonth(currentMonth + currentYear); } }
And here is what is generated:/** * License Agreement. * * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF) * * Copyright (C) 2007 Exadel, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package ca.whitewaterweb.renderkit.html; // // Imports // import java.util.Iterator; import java.util.Collection; import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.ajax4jsf.framework.renderer.ComponentsVariableResolver; import org.ajax4jsf.framework.renderer.ComponentVariables; // // // import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase; /** * Renderer for component class ca.whitewaterweb.renderkit.html.EventCalendarRenderer */ public class EventCalendarRenderer extends AjaxComponentRendererBase { public EventCalendarRenderer () { super(); } // // Declarations // // // // private String convertToString(Object obj ) { return ( obj == null ? "" : obj.toString() ); } private String convertToString(boolean b ) { return String.valueOf(b); } private String convertToString(int b ) { return b!=Integer.MIN_VALUE?String.valueOf(b):""; } private String convertToString(long b ) { return b!=Long.MIN_VALUE?String.valueOf(b):""; } /** * Get base component class, targetted for this renderer. Used for check arguments in decode/encode. * @return */ protected Class getComponentClass() { return ca.whitewaterweb.component.UIEventCalendar.class; } public void doEncodeEnd(ResponseWriter writer, FacesContext context, ca.whitewaterweb.component.UIEventCalendar component, ComponentVariables variables) throws IOException { java.lang.String clientId = component.getClientId(context); writer.startElement("div", component); getUtils().writeAttribute(writer, "id", clientId ); getUtils().writeAttribute(writer, "title", component.getAttributes().get("titleValue") ); // // pass thru attributes // getUtils().encodeAttributesFromArray(context,component,new String[] { "class" , "dir" , "lang" , "onclick" , "ondblclick" , "onkeydown" , "onkeypress" , "onkeyup" , "onmousedown" , "onmousemove" , "onmouseout" , "onmouseover" , "onmouseup" , "style" , "title" , "xml:lang" }); // // // writer.startElement("table", component); getUtils().writeAttribute(writer, "cellpadding", "0" ); getUtils().writeAttribute(writer, "cellspacing", "0" ); getUtils().writeAttribute(writer, "class", "dr-table rich-table " + convertToString(component.getAttributes().get("styleClass")) ); getUtils().writeAttribute(writer, "id", clientId ); getUtils().writeAttribute(writer, "style", component.getAttributes().get("style") ); writer.startElement("tr", component); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Sunday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Sunday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Monday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Monday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Tuesday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Tuesday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Wednesday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Wednesday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Thursday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Thursday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Friday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Friday"),null); writer.endElement("th"); writer.startElement("th", component); getUtils().writeAttribute(writer, "abbr", "Saturday" ); getUtils().writeAttribute(writer, "scope", "col" ); writer.writeText(convertToString("Saturday"),null); writer.endElement("th"); writer.endElement("tr"); renderChildren(context, component); writer.endElement("table"); writer.startElement("input", component); getUtils().writeAttribute(writer, "name", convertToString(clientId) + "monthValue" ); getUtils().writeAttribute(writer, "type", "hidden" ); getUtils().writeAttribute(writer, "value", component.getAttributes().get("monthValue") ); writer.endElement("input"); writer.startElement("input", component); getUtils().writeAttribute(writer, "name", convertToString(clientId) + "yearValue" ); getUtils().writeAttribute(writer, "type", "hidden" ); getUtils().writeAttribute(writer, "value", component.getAttributes().get("yearValue") ); writer.endElement("input"); writer.endElement("div"); } public void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component); doEncodeEnd(writer, context, (ca.whitewaterweb.component.UIEventCalendar)component, variables ); ComponentsVariableResolver.removeVariables(this, component); } }
The generated renderer does not extend the base renderer that I created according to the documentation.
What is happening?
Thanks for looking into this
Les McKinney -
3. Re: Richfaces CDK problem
artdaw Nov 24, 2008 12:07 PM (in response to lmckinney)Les McKinney, please, check the Renderer Baseclass in your Template. It should be your Baseclass, e.g. ca.whitewaterweb.renderkit.EventCalendarRenderer.