Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 素数取随机形式ID_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf 素数取随机形式ID

Jsf 素数取随机形式ID,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,在primefaces中刷新页面的方法是什么? 我试过了 <p:commandLink actionListener="#{legendcontroller.addEditLegendType(true,false)}" update="legendform:pnlform" >Add Legend</p:commandLink> <p:commandLink immediate="true" actionListener="#{legendcontrol

在primefaces中刷新页面的方法是什么? 我试过了

<p:commandLink   actionListener="#{legendcontroller.addEditLegendType(true,false)}" update="legendform:pnlform" >Add Legend</p:commandLink>

<p:commandLink   immediate="true" actionListener="#{legendcontroller.addEditLegendType(false,false)}" update="legendform:pnlform" >View Legend  </p:commandLink>

<p:commandLink id="editLink" value="Edit" actionListener="#{legendcontroller.editLegendType(legendtype)}" update=":legendform:pnlform"  process="@this"/>
添加图例
视图图例
第三个将在带有datatable的页面中生成错误。我得到的错误是:

找不到从“j_idt22:legendviewdatatable:0:editLink”引用的表达式为“pnlform”的组件。我想在点击编辑并打开editpanel时刷新表单。当我点击delete时,我只想刷新datatable

完整的html:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <title>Legend</title>
    </h:head>
    <h:body>
        <ui:composition template="/generalTemplate.xhtml">
            <ui:define name="title">Legend </ui:define>
            <ui:define name="content" >
                <f:view>
                    <h:form id="legendform" prependId="false" >
                        <p:panel id="pnlform">
                            <f:facet name="header">
                                <p:commandLink   actionListener="#{legendcontroller.addEditLegendType(true,false)}" update="legendform:pnlform" >Add Legend</p:commandLink>
                                <p:commandLink   immediate="true" actionListener="#{legendcontroller.addEditLegendType(false,false)}" update="legendform:pnlform" >View Legend  </p:commandLink>
                            </f:facet>

                            <p:panel id="addeditpnl" rendered="#{legendcontroller.addLegendBool or legendcontroller.editLegendBool}" style="width:100%">
                                <h:panelGrid columns="2"  >
                                    <h:outputLabel value="Legend Name" for="legendname" />
                                    <h:inputText id="legendname" value="#{legendcontroller.legendType.legendname}" title="Legendname" required="true" requiredMessage="The Legendname field is required."/>
                                    <h:outputLabel value="Legend Description" for="legendDesc" />
                                    <h:inputText id="legendDesc" value="#{legendcontroller.legendType.legendDesc}" title="LegendDesc" />
                                    <h:outputLabel value="Legend For" for="legendfor" />
                                    <h:inputText id="legendfor" value="#{legendcontroller.legendType.legendfor}" title="Legendfor" required="true" requiredMessage="The Legendfor field is required."/>
                                </h:panelGrid>

                                <p:dataTable id="addeditdtable" value="#{legendcontroller.legendType.legendList}" var="legend" style="width:100%">

                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Legend SN"/>
                                        </f:facet>
                                        <h:inputText value="#{legend.legendSn}"/>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="LegendDesc"/>
                                        </f:facet>
                                        <h:inputText value="#{legend.legendDesc}"/>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Lower Range"/>
                                        </f:facet>
                                        <h:inputText value="#{legend.lowerrange}"/>
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Upper Range"/>
                                        </f:facet>
                                        <h:inputText value="#{legend.upperrange}"/>
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Color"/>
                                        </f:facet>
                                        <p:colorPicker value="#{legend.color}"/>
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="ADD/Delete"/>
                                        </f:facet>
                                        <p:commandLink value="Add" actionListener="#{legendcontroller.addLegendAfter(legend)}"  update="addeditdtable" process="@this"/>
                                        <h:outputText value=" / "/>
                                        <p:commandLink value="Delete" actionListener="#{legendcontroller.removeLegendDTO(legend)}" update="addeditdtable" process="@this"/>
                                    </p:column>

                                    <f:facet name="footer">
                                        <p:commandButton  value="SAVE" action="#{legendcontroller.saveLegend()}"/>
                                    </f:facet>
                                </p:dataTable>

                            </p:panel>





                            <p:dataTable id="legendviewdatatable" value="#{legendcontroller.allLegendType()}" rendered="#{!legendcontroller.addLegendBool and !legendcontroller.editLegendBool}" var="legendtype"  style="width:100%">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Legendname"/>
                                    </f:facet>
                                    <h:outputText value="#{legendtype.legendname}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="LegendDesc"/>
                                    </f:facet>
                                    <h:outputText value="#{legendtype.legendDesc}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Legendfor"/>
                                    </f:facet>
                                    <h:outputText value="#{legendtype.legendfor}"/>
                                </p:column>

                                <p:column id="editDelCol">
                                    <f:facet name="header">
                                        <h:outputText value="Edit/Delete"/>
                                    </f:facet>    
                                    <p:commandLink id="editLink" value="Edit" actionListener="#{legendcontroller.editLegendType(legendtype)}" update=":legendform:pnlform"  process="@this"/>
                                    <h:outputText value=" / "/>
                                    <p:commandLink id="deleteLink" value="Delete" actionListener="#{legendcontroller.deleteLegendType(legendtype)}" update="legendviewdatatable" process="@this" />

                                </p:column>
                            </p:dataTable>

                        </p:panel>
                    </h:form>
                </f:view>
            </ui:define>
        </ui:composition >
    </h:body>
</html>

传奇
传奇
添加图例
视图图例
最后我发现primefaces没有使用给定的id,而是使用随机id:

<form id="j_idt12" name="j_idt12" method="post" action="/Configuration/LegendManager/LegendType.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt12" value="j_idt12">
<div id="j_idt12:j_idt13" class="ui-toolbar ui-widget ui-widget-header ui-corner-all ui-helper-clearfix"><div class="ui-toolbar-group-left"><button id="j_idt12:j_idt15" name="j_idt12:j_idt15" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" title="Welcome" type="submit" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-disk"></span><span class="ui-button-text ui-c">Home</span></button><button id="j_idt12:j_idt16" name="j_idt12:j_idt16" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" title="Configuration" type="submit" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-disk"></span><span class="ui-button-text ui-c">Configuration</span></button></div><div class="ui-toolbar-group-right"><span id="j_idt12:j_idt18" class="ui-menubutton"><button id="j_idt12:j_idt18_button" name="j_idt12:j_idt18_button" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-triangle-1-s"></span><span class="ui-button-text ui-c">sugandha</span></button></span></div></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="2044288989474132123:952602282947229034" autocomplete="off">
</form>

家庭配置Sugandha

既然您使用了
prependId=“false”
,您应该只使用
update=“pnlform”
,或者删除
prependId=“false”
,这样您就可以保留
update=“yourformname:yourid”
update=“:yourid”

更多信息:


按如下方式更改代码:
或不带
prependId
属性,然后从其他任何位置使用
update=“:legendform:pnlform”
属性引用此表单中的嵌套组件。
在您的情况下,如果要设置
prependId=false
,然后以相同的形式从
中的嵌套组件引用,则应使用
update=“:pnlform”
进行更新。
这是因为
有自己的我遇到错误:找不到从“j_idt22:legendviewdatatable:0:editLink”引用的表达式为“pnlform”的组件。是否将
替换为
?是。这就是为什么错误是pnlform。我很困惑为什么这不起作用?我发现它使用的是随机表单id。编辑。@Kitex很奇怪,您项目中的其他表单也在这样做吗?