我正在使用primefaces。当我点击查看按钮时,发生以下异常 找不到“form1:j_idt78”中引用标识符“company”的组件。 哪里有错误我能找到请帮帮我。 提前谢谢
xhtml文件是
<h:form dir="#{localeControllerBean.direction}">
<p:panel header="#{msg['list_category']}" id="empDetails"
style="font-size:small;height:593px;width:100%; background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#a7b5c6), color-stop(100%,#f2f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #a7b5c6 1%,#f2f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #a7b5c6 1%,#f2f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #a7b5c6 1%,#f2f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #a7b5c6 1%,#f2f7f7 100%);">
<p:growl id="msgs" autoUpdate="true" display="icon"></p:growl>
<f:event listener="#{localeControllerBean.islang}" type="preRenderView" />
<p:dataTable id="dt1" var="cat" value="#{cateagoryBean.categorynames}"
rowKey="#{cat.category_id}"
selection="#{cateagoryBean.category}"
resizableColumns="true" selectionMode="single" paginator="true"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10"
style="width:99%; margin-left: 10px; margin-top:5px; top:10px;">
<f:facet name="header">
#{msg['list_category']}
</f:facet>
<p:column>
<f:facet name="header">
#{msg['category_name']}
</f:facet>
<h:outputText value="#{cat.category_name}" />
</p:column>
<p:column>
<f:facet name="header">
#{msg['type']}
</f:facet>
<h:outputText value="#{cat.typeName}" />
</p:column>
<p:column>
<f:facet name="header">
#{msg['status']}
</f:facet>
<h:outputText value="#{cat.status}" />
</p:column>
<f:facet name="footer">
<p:commandButton id="viewCommand" value="#{msg['view']}"
icon="ui-icon-search"
action="#{cateagoryBean.viewcat(cateagoryBean.category)}" ajax="false" />
</f:facet>
<f:facet name="footer">
<p:commandButton id="updateCommand" type="submit"
value="#{msg['update']}" icon="ui-icon-arrowrefresh-1-w"
action="#{cateagoryBean.editcat(cateagoryBean.category)}"
ajax="false" />
</f:facet>
<f:facet name="footer">
<p:commandButton id="deleteCommand" type="submit"
value="#{msg['delete']}" icon="ui-icon-close"
action="#{cateagoryBean.deletecategory(cateagoryBean.category)}"
ajax="false" />
</f:facet>
</p:dataTable>
</p:panel>
</h:form>
下一个xhtml页面是
<h:form enctype="multipart/form-data" dir="#{localeControllerBean.direction}" id="form1">
<div id="add">
<p:growl id="msgs" autoUpdate="true" display="icon" style="left:20px"></p:growl>
</div>
<p:panel header="#{msg['categorydetail']}" style="font-size:small">
<h:panelGrid columns="2">
<p:outputLabel for="cname" value="#{msg['category_name']}"
styleClass="label" />
<h:outputText id="cname" value="#{cateagoryBean.category.category_name}"
required="true" requiredMessage="Please Enter Category Name"
styleClass="input"/>
<p:outputLabel for="description" value="#{msg['description']}"
styleClass="label" />
<h:outputText id="description" value="#{cateagoryBean.category.description}"
required="true" requiredMessage="Please enter sponsor address"
styleClass="input" />
<h:outputLabel for="selectType" value="#{msg['type']}"/>
<h:outputText id="selectType" value="#{cateagoryBean.category.typeName}"
required="true" requiredMessage="Please enter sponsor address"
styleClass="input" />
<p:outputLabel for="company" value="#{msg['emp_selectcompany']}" styleClass="label"/>
<h:outputText id="selectType" value="#{cateagoryBean.category.tbl_company.comapnyname}"
required="true" requiredMessage="Please enter sponsor address"
styleClass="input" />
</h:panelGrid>
</p:panel>
</h:form>
please tell me where is error.
答案 0 :(得分:1)
你outputLabel正在寻找一个id = company的组件,但没有:
<p:outputLabel for="company" value="#{msg['emp_selectcompany']}" styleClass="label"/>
<h:outputText id="selectType" value="#{cateagoryBean.category.tbl_company.comapnyname}"
required="true" requiredMessage="Please enter sponsor address"
styleClass="input" />
您应该将输出文本的id从h重命名为:outputText id =“selectType”to id =“company”