You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ray Clark <rc...@yahoo.com> on 2005/01/01 04:12:15 UTC

Re: custom dataTable and commandButton

I was just trying different things tonight and oh my
gosh, I found a combination that works.  If I change
the UIRptTableColHdr class to extend UIComponentBase
instead of HtmlDataTable it worked.  Does this help
someone figure out the problem?  I don't know if it is
a bug in the RI or if I was just extending the wrong
class.  Any ideas?

Thanks,
Ray

--- Ray Clark <rc...@yahoo.com> wrote:

> Ok here goes.
> 
> What I have is a set of 5 custom tags to output a
> <table> with its associated tags.  I've boiled it
> down
> about as far as it can go.  The commandButton would
> go
> in the col tag.  If it is just in the col tag by
> itself, it works fine.  If it is in a col tag inside
> a
> row tag it works fine.  But if it is in a col tag
> inside a row tag inside a colHdr tag, it fails. 
> What
> happens is, when it fails, all phases are executed,
> but the method isn't called.  I haven't include the
> tag that outputs the <table> tag and another tag. 
> They don't seem to make any difference in the
> execution.  So this is about as trimmed down as I
> can
> make it I think.
> 
> I really appreciate your help.  Let me know if you
> need anything else.
> 
> Here is the jsp:
> 
> <%@ taglib uri="http://java.sun.com/jsf/html"
> prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"
> prefix="f"%>
> <%@ taglib uri="/WEB-INF/tld/customjsf.tld"
> prefix="cjsf" %>
> 
> <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0
> transitional//en">
> 
> <html>
> 	<f:view>
> 		<head><title>Sample page to test commandButton
> inside custom tags</title></head>
> 		<body>
> 			<h:form id="tblmaintForm">
> 				<h:panelGrid columns="1">
> 					<cjsf:col>
> 						<h:commandButton
> action="#{allAuthUser.sortAppIdAscButton}" value="1
> works"/>
> 					</cjsf:col>
> 					<cjsf:row>
> 						<cjsf:col>
> 							<h:commandButton
> action="#{allAuthUser.sortAppIdAscButton}" value="2
> works"/>
> 						</cjsf:col>
> 					</cjsf:row>
> 					<cjsf:colHdr>
> 						<cjsf:row>
> 							<cjsf:col>
> 								<h:commandButton
> action="#{allAuthUser.sortAppIdAscButton}" value="3
> fails"/>
> 							</cjsf:col>
> 						</cjsf:row>
> 					</cjsf:colHdr>
> 				</h:panelGrid>
> 			</h:form>
> 	    </body>
> 	</f:view>
> </html>
> 
> Here are the component classes:
> 
> /*
>  * Created on Dec 19, 2004
>  *
>  */
> package
> com.monsanto.ag_it.fieldops.aim.tblmaint.component;
> 
> import javax.faces.component.UIColumn;
> 
> /**
>  * @author rcclark
>  *
>  * This component implements the RptTableColTag
>  */
> public class UIRptTableCol extends UIColumn {
> 	
> 	public UIRptTableCol() {
> 		setRendererType("tblmaint.rptTableColRenderer");
> 	}
> }
> 
> /*
>  * Created on Dec 19, 2004
>  *
>  */
> package
> com.monsanto.ag_it.fieldops.aim.tblmaint.component;
> 
> import javax.faces.component.html.HtmlDataTable;
> 
> /**
>  * @author rcclark
>  *
>  * This component implements the RptTableColHdrTag
>  */
> public class UIRptTableColHdr extends HtmlDataTable
> {
> 			
> 	public UIRptTableColHdr() {
> 	
> setRendererType("tblmaint.rptTableColHdrRenderer");
> 	}
> }
> 
> /*
>  * Created on Dec 19, 2004
>  *
>  */
> package
> com.monsanto.ag_it.fieldops.aim.tblmaint.component;
> 
> import javax.faces.component.UIOutput;
> 
> /**
>  * @author rcclark
>  *
>  * This component implements the RptTableRowTag
>  */
> public class UIRptTableRow extends UIOutput {
> 	
> 	public UIRptTableRow() {
> 		setRendererType("tblmaint.rptTableRowRenderer");
> 	}
> }
> 
> Here are the renderers:
> 
> /*
>  * Created on Dec 19, 2004
>  *
>  */
> package
> com.monsanto.ag_it.fieldops.aim.tblmaint.renderer;
> 
> import java.io.IOException;
> import java.util.Iterator;
> 
> import javax.faces.component.UIComponent;
> import javax.faces.context.FacesContext;
> import javax.faces.context.ResponseWriter;
> import javax.faces.render.Renderer;
> 
> import
>
com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableCol;
> import
>
com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableColHdr;
> 
> /**
>  * @author rcclark
>  *
>  * Renderer for the RptTableTag
>  */
> public class RptTableColRenderer extends Renderer {
> 	
> 	private String tagType = null;
> 
> 	public void encodeBegin(FacesContext context,
> UIComponent rptTableCol) 
> 			throws IOException {
> 
> 		// First determine if this is a th or td cell
> 		Object rptTblSection =
> rptTableCol.getParent().getParent();
> 		
> 		tagType = "td";
> 		if (rptTblSection instanceof UIRptTableColHdr) {
> 			tagType = "th";
> 		}
> 
> 		ResponseWriter writer =
> context.getResponseWriter();
> 		
> 		UIRptTableCol rptTblCol = (UIRptTableCol)
> rptTableCol;
> 
> 		writer.write("\t\t\t");
> 		writer.startElement(tagType, rptTableCol);
> 
> //System.out.println("col id=" + (String)
> rptTableCol.getAttributes().get("id"));
> //		if (!rptTblCol.getId().substring(0,
> 3).equals("_id")) {
> 			writer.writeAttribute("id",
> rptTblCol.getClientId(context), null);
> //		}
> 
> 		String colClass = (String)
> rptTableCol.getAttributes().get("colClass");
> 		if (colClass != null) {
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com