我试图让使用Facelet标记文件,@ Balusc以前的答案在panelGrid的内部JSF 1.2组件的可重复使用的组如何使JSF复合元件的网格? 作为参考。 我抄/WEB-INF/tags/input.xhtml和example.taglib.xml和主要应用XHTML。 但是,我遇到了一些问题。
1.如果我没有通过ID和简单做
<my:input id="cat" type="text" label="FirstName" bean="#{bean}" property="fName" required="true" />
<my:input id="dog" type="text" label="LastName" bean="#{bean}" property="lName" required="true />
在我的主要XHTML和打开该网页,我得到java.lang.IllegalArgumentException异常和异常跟踪:
java.lang.IllegalArgumentException
at javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:543)
at javax.faces.component.UIComponentBase.setId(UIComponentBase.java:351)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:151)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:119)
at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:268)
at com.sun.facelets.tag.UserTagHandler.apply(UserTagHandler.java:98)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:524)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
2.To闯过这一点,当我在我的代码传递的id值
<my:input id="cat" type="text" label="FirstName" bean="#{bean}" property="fName" required="true" />
<my:input id="dog" type="text" label="LastName" bean="#{bean}" property="lName" required="true />
我得到重复的ID为组件j_id2:猫错误。
java.lang.IllegalStateException: duplicate Id for a component j_id2:cat
at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:68)
at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
at org.ajax4jsf.application.AjaxStateManager.getTreeStructureToSave(AjaxStateManager.java:187)
at org.ajax4jsf.application.AjaxStateManager.buildViewState(AjaxStateManager.java:498)
at org.ajax4jsf.application.AjaxStateManager.saveSerializedView(AjaxStateManager.java:451)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:615)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
3.To突破这个,我删除了所有的C:当,只是不停地在input.xhtml“文本”的一个输入类型,现在我看到2个文本框的渲染,但是当我做的查看源代码,我看
<tr>
<td>
<c:set var="id" value="cat"></c:set>
<c:set var="required" value="true"></c:set>
</td>
<td><label for="j_id2:cat">First Name: * </label></td>
<td><input id="j_id2:cat" type="text" name="j_id2:cat" value="Smith" /></td>
</tr>
<tr>
<td></td>
<td>
<c:set var="id" value="dog"></c:set>
<c:set var="required" value="true"></c:set>
</td>
<td><label for="j_id2:dog">Last Name: * </label></td>
</tr>
<tr>
<td><input id="j_id2:dog" type="text" name="j_id2:dog" value="Joe" /></td>
<td></td>
</tr>
我期待2行,但看到3行instead.Also我没;吨希望C:在标签文件集定义是我的TD图的一部分。
任何指针将不胜感激。