提前感谢任何指示/想法。
我正在使用JSF 2.1,Primefaces 3.2和Jboss7.0 Final。我的问题是以下.XHTML抛出:
javax.servlet.ServletException: mainForm:testTabs_Tabs-tabs:j_idt34
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137)
com.maketechnologies.framework.web.SecurityFilter.doFilter(SecurityFilter.java:34)
root cause
java.lang.IllegalArgumentException: mainForm:testTabs_Tabs-tabs:j_idt34
javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:548)
javax.faces.component.UIComponentBase.setId(UIComponentBase.java:363)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doExistingComponentActions(ComponentTagHandlerDelegateImpl.java:428)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:155)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(ImplementationHandler.java:81)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(CompositeComponentTagHandler.java:348)
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:190)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:103)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:178)
com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:395)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:366)
com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:108)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:164)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:744)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.render(CodiLifecycleWrapper.java:126)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137)
com.maketechnologies.framework.web.SecurityFilter.doFilter(SecurityFilter.java:34)
这是我的XHTML代码(我无法发布所有内容,导致格式化问题):
<p:outputPanel id="testTabs_Tabs" layout="block" styleClass="tabLayout">
<p:tabView dynamic="true" id="testTabs_Tabs-tabs" onTabChange="if (isDirtyAction()) {return false;}">
<p:tab id="testTabs_Tabs-Tab1" label="#{testTabsMsg.testTabs_Tabs_Tab1}" title="#{testTabsMsg.testTabs_Tabs_Tab1}">
<p:outputPanel id="Tabs_Tab1" layout="block" styleClass="formLayout">
<table class="formLayout">
<tbody>
<tr>
<td colspan="2">
<p:outputPanel id="Tab1_TestPanel" layout="block" styleClass="formLayout">
<table class="formLayout">
<tbody>
<tr>
<td colspan="2">
<p:outputPanel id="TestPanel_UpperPanel" layout="block" styleClass="formLayout">
<table class="formLayout">
<tbody>
<tr>
<td colspan="2">
<p:outputPanel id="UpperPanel_Buttons" layout="block" styleClass="formLayout">
<p:outputPanel id="UpperPanel_Buttons_buttonGroup" layout="block" styleClass="buttonGroup">
<t:commandButton action="#{testTabs.doSomething}" disabled="#{testTabs.doSomethingDisabled}" id="buttons_doSomething" value= "#{testTabsMsg.testTabs_Tabs_Tab1_TestPanel_UpperPanel_Buttons_doSomething}" />
</p:outputPanel>
</p:outputPanel>
</td>
</tr>
</tbody>
</table>
</p:outputPanel>
</td>
</tr>
<tr>
<td colspan="2">
<p:outputPanel id="TestPanel_ShowMeHideMe">
<p:outputPanel id="TestPanel_ShowMeHideMe_inner" layout="block" rendered="#{testTabs.showMeHideMeRendered}" styleClass="formLayout">
<table class="formLayout">
<tbody>
<tr>
<th>
<t:label forId="Hi:Hi" value="#{testTabsMsg.testTabs_Tabs_Tab1_TestPanel_ShowMeHideMe_Hi}"/>
</th>
<td>
<t:inputText id="Hi" label="#{testTabsMsg.testTabs_Tabs_Tab1_TestPanel_ShowMeHideMe_Hi}" value="#{testTabs.testText}"/>
</td>
</tr>
</tbody>
</table>
<p:outputPanel id="TestPanel_ShowMeHideMe_buttonGroup" layout="block" styleClass="buttonGroup">
<t:commandButton action="#{testTabs.done}" ajax="true" id="showMeHideMe_done" updateTarget="@form" value="#{testTabsMsg.testTabs_Tabs_Tab1_TestPanel_ShowMeHideMe_done}"/>
</p:outputPanel>
</p:outputPanel>
</p:outputPanel>
</td>
</tr>
</tbody>
</table>
</p:outputPanel>
</td>
</tr>
</tbody>
</table>
</p:outputPanel>
</p:tab>
<p:tab action="#{testTabs.tab2}" id="testTabs_Tabs-Tab2" label="#{testTabsMsg.testTabs_Tabs_Tab2}" title="#{testTabsMsg.testTabs_Tabs_Tab2}"/>
</p:tabView>
</p:outputPanel>
</td>
</tr>
</tbody>
</table>
</p:outputPanel>
</ui:define>
</ui:composition>
这是我的支持bean代码:
package ca.sandbox;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
import org.jboss.seam.international.status.Messages;
import com.ocpsoft.pretty.faces.annotation.URLAction;
import com.ocpsoft.pretty.faces.annotation.URLMapping;
import com.ocpsoft.pretty.faces.annotation.URLMappings;
import ca.sandbox.AbstractBackingBean;
@Named
@ViewAccessScoped
@URLMappings(mappings = {
@URLMapping(id = "testTabs", pattern = "/sandbox/testTabs/#{iid : testTabs.id}", viewId = "/sandbox/testTabs.jsf"),
@URLMapping(id = "testTabsNew", pattern = "/sandbox/testTabs", viewId = "/sandbox/testTabs.jsf") })
public class TestTabs extends AbstractBackingBean implements Serializable {
private static final long serialVersionUID = 1L;
private String hi;
private Long id;
private String testText = "this is working!!!";
private boolean panelShown = false;
public TestTabs() {
}
public String getHi() {
return hi;
}
public void setHi(String hi) {
this.hi = hi;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@URLAction
public void load() {
}
@PostConstruct
public void init() {
System.out.println("break here");
}
public String done() {
panelShown = false;
return null;
}
public String doSomething() {
panelShown = true;
return null;
}
public boolean getShowMeHideMeRendered() {
return panelShown;
}
public boolean getDoSomethingDisabled() {
return panelShown;
}
public String getTestText() {
return testText;
}
public void setTestText(String testText) {
this.testText = testText;
}
// @formatter:off
}
答案 0 :(得分:0)
错误是说mainForm:testTabs_Tabs-tabs
组件的一个参数是错误的。经过一番研究,我发现p:tab
没有动作组件属性,
<p:tab action="#{testTabs.tab2}" id="testTabs_Tabs-Tab2" label="#{testTabsMsg.testTabs_Tabs_Tab2}" title="#{testTabsMsg.testTabs_Tabs_Tab2}"/>
尝试将tab2的代码更改为此
<p:tab id="testTabs_Tabs-Tab2" label="#{testTabsMsg.testTabs_Tabs_Tab2}" title="#{testTabsMsg.testTabs_Tabs_Tab2}"/>