当前位置: 首页 > 知识库问答 >
问题:

PrimeFaces commandButton actionListener未启动

斜博超
2023-03-14

只有在更新netbeans之后,代码才发生了变化。Netbeans 7.3、JSF2。2、Tomcat 7、jdk1。7,primefaces 4.0。在我的tomcat manager应用程序中有一个工作版本,如果我能够检索到,希望一切都能恢复正常工作,但是我找不到任何关于从tomcat取回文件的信息。所以我的问题是,为什么不开火?这是我按按钮打电话的顺序吗?我不明白为什么这不起作用。

编辑错误我收到后切换形式和对话框位置-

    Jul 10, 2014 11:50:48 AM     com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
    SEVERE: Error Rendering View[/sampleExport.xhtml]
    javax.faces.FacesException: Cannot find component with expression ":searchDialogID" referenced from "mainForm:j_idt22".
    at   org.primefaces.expression.SearchExpressionFacade.resolveComponentInternal(SearchExpressionFacade.java:271)

编辑3修改过的Bean

@ManagedBean
@ViewScoped
public class SampleExportController implements Serializable {


//Variables used to show or hide panels on the webpage
private boolean _addTill = false;
private boolean _allowAddingExport;
private boolean _allowDelExport;
private boolean _allowModExport;
private boolean _allowReading;
private boolean _previousCrop;
private boolean _spreadSelected;
//Variables Used For Whole Form
private ArrayList<Account> _agronomers;

private StreamedContent _file;
private ArrayList<String> _growers;
private SampleSearch _search;
private LabSampleHelper _labHelper;
private ArrayList<AdminLabNumber> _labNumbers;
private NutrientsGuide _nutriGuide;
private SampleAdminHelper _saHelper;
private List<String> _sampleTypes;
private SampleAlter _selectedSample;
private AdminLabNumber _selectedLab;
private QueryHelper _qHelper;
private List<String> _years;

public SampleExportController() {
    AllowedRights awdRight = AllowedRights.getAllowedRights();
    Access rights = awdRight.getAccessRigths("exportSample");
    if (rights != null) {
        _allowAddingExport = rights.getOperationAdd();
        _allowDelExport = rights.getOperationDel();
        _allowModExport = rights.getOperationMod();
        _allowReading = rights.getReadAccess();
    } else {
        _allowAddingExport = false;
        _allowDelExport = false;
        _allowModExport = false;
        _allowReading = false;
    }
    _search = new SampleSearch();
    _saHelper = new SampleAdminHelper();
    _qHelper = new QueryHelper();
    _years = _saHelper.getYears();
    if (_years != null && !_years.isEmpty()) {
        _search.setYear(_years.get(0));
    }
    _sampleTypes = _saHelper.getSampleTypes();
    _labHelper = new LabSampleHelper();
}




public void initSearch() {
    AccountHelper acHelper = new AccountHelper();
    _agronomers = acHelper.getAllAgronomers();
    SampleAdminHelper saHelper = new SampleAdminHelper();
    _growers = saHelper.getAllGrowers();
}

public void loadSearch() {
    UIComponent table = FacesContext.getCurrentInstance().getViewRoot().findComponent(":mainForm:DTsamples");
    table.setValueExpression("sortBy", null);
    _search.setStage("Completed");
    _labNumbers = _saHelper.exportSampleSearch(_search);
    ExportFormatHelper efHelper = new ExportFormatHelper();
    for (int i = 0; i < _labNumbers.size(); i++) {
        _labNumbers.get(i).addExportSettings(efHelper.getFormats(_labNumbers.get(i).getAccountNumber(), _labNumbers.get(i).getSampleType()));
    }
    //loadExportSettings from account
    _agronomers.clear();
    _growers.clear();
}



/**
 * @return the _search
 */
public SampleSearch getSearch() {
    return _search;
}

/**
 * @return the _labNumbers
 */
public ArrayList<AdminLabNumber> getLabNumbers() {
    return _labNumbers;
}

/**
 * @return the _agronomers
 */
public ArrayList<Account> getAgronomers() {
    return _agronomers;
}

/**
 * @return the _growers
 */
public ArrayList<String> getGrowers() {
    return _growers;
}

/**
 * @return the _selectedSample
 */
public SampleAlter getSelectedSample() {
    return _selectedSample;
}

/**
 * @param selectedSample the _selectedSample to set
 */
public void setSelectedSample(SampleAlter selectedSample) {
    this._selectedSample = selectedSample;
    //This gets the value of the initial till level from the sample
    _initialTill = _selectedSample.getTilled();
    _initialPreviousCrop = _selectedSample.getPreviousCrop();
    if (selectedSample.getSampleType().equalsIgnoreCase("Soil")) {

        if (_crop1 == null | _crop2 == null || _crop3 == null) {
            _crop1 = new CropGuide(_qHelper, _selectedSample);
            _crop2 = new CropGuide(_qHelper, _selectedSample);

            _crop3 = new CropGuide(_qHelper, _selectedSample);
        }
        _nutriGuide = new NutrientsGuide(_crop1.getRec(),_selectedSample);
        boolean flag1, flag2, flag3;
        flag1 = _crop1.refresh();
        flag2 = _crop2.refresh();
        flag3 = _crop3.refresh();
        if (flag1 || flag2 || flag3) {
            RequestContext.getCurrentInstance().update("nutrientguides");
        }
    }
}

/**
 * @return the _file
 */
public StreamedContent getFile() {
    return _file;
}


/**
 * @return the _selectedLab
 */
public AdminLabNumber getSelectedLab() {
    return _selectedLab;
}

/**
 * @param selectedLab the _selectedLab to set
 */
public void setSelectedLab(AdminLabNumber selectedLab) {
    this._selectedLab = selectedLab;
}


/**
 * @return the _years
 */
public List<String> getYears() {
    return _years;
}

/**
 * @return the _sampleTypes
 */
public List<String> getSampleTypes() {
    return _sampleTypes;
}


public void setPreviousCrop(boolean _previousCrop) {
    this._previousCrop = _previousCrop;
}

}

xhtml大部分是满的

<!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:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">
<h:body>
    <ui:composition template="template/desktop_viewer.xhtml">
        <ui:define name="PageName">
            <title>Sample Export</title> 
        </ui:define>

        <ui:define name="PageHeader">
            Sample Export
        </ui:define>

        <ui:define name="PageLocation">
            Viewer
        </ui:define>  

        <ui:define name="Body" >
            <script type="text/javascript">
                function start() {
                    statusDialog.show();
                }

                function stop() {
                    statusDialog.hide();
                }
            </script> 
            <h:form id="mainForm" rendered="#{sampleExportController.allowReading eq true}">
                <p:dialog modal="true" widgetVar="statusDialog" header="Status" resizable="false" draggable="false" closable="false" appendToBody="true">
                    <p:graphicImage value="./resources/images/ajaxloading.gif" />
                </p:dialog>

                <p:ajaxStatus style="width:16px;height:16px;" id="ajaxStatusPanel">
                    <f:facet name="start">
                        <h:graphicImage value="./resources/images/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:growl id="growl" showDetail="true" autoUpdate="true"/>

                <p:commandButton oncomplete="searchDialog.show()" update=":innerSearch:searchDialogID" value="Search" icon="ui-icon-search" actionListener="#{sampleExportController.initSearch}"/>  
                <p:dataTable id="DTsamples" widgetVar="DTsamplesVw" var="labNumbers" value="#{sampleExportController.labNumbers}" 
                             paginator="true" rows="10" scrollable="true" rowStyleClass="#{labNumbers.rowColorByType}">
                    <p:column style="width:10px">
                        <p:rowToggler />
                    </p:column>
                    <p:column headerText="LabNumber" footerText="LabNumber">
                        #{labNumbers.number} 
                    </p:column>
                    <p:column headerText="Sample Type" footerText="Sample Type">
                        #{labNumbers.sampleType} 
                    </p:column>
                    <p:rowExpansion > 
                        <p:panelGrid style="width: 460px;">
                            <f:facet name="header">  
                                <p:row>
                                    <p:column colspan="1" style="width: 320px">
                                        Submitter
                                    </p:column>
                                    <p:column colspan="1" style="width:150px">
                                        Lab Number Report Export  
                                    </p:column>
                                    <p:column colspan="1" style="width: 280px">
                                        Lab Number CSV Export 
                                    </p:column>
                                </p:row>
                            </f:facet>  
                            <p:row>
                                <p:column>
                                    <h:panelGrid columns="1" styleClass="Ignore" >                                           
                                        <h:outputText value=" #{''.concat(labNumbers.getSamples().get(0).agronomer.accountNumber).concat(' - ').concat(labNumbers.getSamples().get(0).agronomer.lastName ).concat(' , ').concat(labNumbers.getSamples().get(0).agronomer.firstName)}"/>

                                        <h:outputText value=" #{'Email: '.concat(labNumbers.getSamples().get(0).agronomer.primaryEmail)}"/>
                                        <h:outputText value=" #{'Email 2: '.concat(labNumbers.getSamples().get(0).agronomer.email2)}"/>
                                        <h:outputText value=" #{'Email 3: '.concat(labNumbers.getSamples().get(0).agronomer.email3)}"/>
                                    </h:panelGrid>
                                </p:column>
                                <p:column style="text-align: center;">

                                    <h:panelGrid styleClass="Ignore">

                                        <p:commandLink ajax="false" id="AlternativeValues" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateAlternativeValueReport(labNumbers,false)}">
                                            <p:fileDownload value ="#{sampleExportController.file}" />
                                        </p:commandLink>

                                        <p:commandLink ajax="false" id="multiPdf" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateMultiSampleReportPDFLab(labNumbers,false)}">  
                                                 <p:fileDownload value="#{sampleExportController.file}" />  
                                            <p:graphicImage value="./resources/images/pdf.png" alt="Download the report by lab Number as a PDF." title="Normal Report"/>  
                                        </p:commandLink> 

                                        <p:commandLink ajax="false" id="multiPdfPage" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateMultiSampleReportPDFLab(labNumbers,true)}" rendered="#{labNumbers.sampleType eq 'Manure'}">  
                                            <p:fileDownload value="#{sampleExportController.file}" />  
                                            <p:graphicImage value="./resources/images/pdf_multi.jpg" alt="Download the report by lab Number as a PDF." title="Sample Per Page Report"/>  
                                        </p:commandLink> 
                                    </h:panelGrid>
                                </p:column>

                                <p:column>
                                    <p:outputLabel for="exportsetting" value="Export Setting:"/>

                                    <p:selectOneMenu id="exportsetting" value="#{labNumbers.selectedExport}" effect="fade" style="width:160px">
                                        <f:selectItem itemLabel="Select One" itemValue="" />
                                        <f:selectItems value="#{labNumbers.exportSettings}" var="export" itemLabel="#{export}" itemValue="#{export}" />
                                        <p:ajax update=":mainForm:DTsamples:downloadLink" event="change" listener="#{sampleExportController.setSelectedLab(labNumbers)}"/> 
                                    </p:selectOneMenu>

                                    <p:commandLink id="downloadLink" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)"   
                                                   disabled="#{empty labNumbers.selectedExport}" actionListener="#{sampleExportController.generateSpreadSheet()}">                                 
                                        <p:graphicImage value="./resources/images/csv.png" alt="Download the report by lab Number as a CSV."/>  
                                        <p:fileDownload value="#{sampleExportController.file}"/>
                                    </p:commandLink>
                                </p:column>
                            </p:row>
                        </p:panelGrid>

                        <p:dataTable id="nested" var="sampleheader" value="#{labNumbers.samples}" scrollable="true"
                                     rowStyleClass="#{sampleheader.rowColorByType}" scrollHeight="150">
                            <p:column headerText="Container ID">  
                                #{sampleheader.containerID}

                            </p:column>
                            <p:column headerText="Sample ID">  
                                #{sampleheader.sampleID}
                            </p:column>
                            <p:column headerText="Field ID">  
                                #{sampleheader.fieldID}
                            </p:column> 
                            <p:column headerText="Grower">  
                                #{sampleheader.grower}
                            </p:column>  
                            <p:column headerText="Sample Type">  
                                #{sampleheader.sampleType}
                            </p:column>
                            <p:column headerText="Notes">  
                                #{sampleheader.note}
                            </p:column>
                            <p:column headerText="View Sample" style="width:8%">                            
                                <p:commandButton update=":viewerID" oncomplete="viewerDialog.show()" process="@this" styleClass="compress" icon="ui-icon-newwin">  
                                    <f:setPropertyActionListener value="#{sampleheader}" target="#{sampleExportController.selectedSample}" />  
                                </p:commandButton>  
                            </p:column>
                        </p:dataTable>
                    </p:rowExpansion>                       
                </p:dataTable> 
            </h:form>            
            <h:outputText value="Nice Try" rendered="#{sampleExportController.allowReading eq false}"/>
            <h:form id="innerSearch"><p:dialog id="searchDialogID" widgetVar="searchDialog" header="Sample search" resizable="false" draggable="false" showEffect="puff"
                      hideEffect="puff" appendToBody="false" modal="true" rendered="#{sampleExportController.allowReading eq true}">

                    <h:panelGrid columns="4">
                        <h:outputText value="Starting Lab Number:"/>
                        <p:inputText value="#{sampleExportController.search.labnumberStart}" maxlength="20"/>
                        <h:outputText value="Ending Lab Number:"/>
                        <p:inputText value="#{sampleExportController.search.labnumberEnd}" maxlength="20"/>
                        <h:outputText value="Starting Container ID:"/>
                        <p:inputText value="#{sampleExportController.search.containerIDStart}" maxlength="11"/>
                        <h:outputText value="Ending Container ID:"/>
                        <p:inputText value="#{sampleExportController.search.containerIDEnd}" maxlength="11"/>
                        <h:outputText value="Season:"/>
                        <p:selectOneMenu  value="#{sampleExportController.search.year}"  
                                          panelStyle="width:150px" effect="fade" var="p" style="width:160px"  
                                          filter="true" filterMatchMode="contains">  
                            <f:selectItem itemLabel="Select One" itemValue="" />  
                            <f:selectItems value="#{sampleExportController.years}" var="year" itemLabel="#{year}" itemValue="#{year}"/>                              
                        </p:selectOneMenu>
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:outputLabel for="acAg" value="Agronomist -- You may now search by any value"/>
                        <p:selectOneMenu id="acAg" value="#{sampleExportController.search.agronomist}" converter="agronomerSampleExportConverter" 
                                         panelStyle="width:170px" effect="fade" var="p" style="width:160px"  
                                         filter="true" filterMatchMode="contains" >  
                            <f:selectItem itemLabel="Select One" itemValue="" />  
                            <f:selectItems value="#{sampleExportController.agronomers}" var="agronomer" itemLabel="#{agronomer.lastName} #{agronomer.company} #{agronomer.firstName} #{agronomer.accountNumber}" itemValue="#{agronomer}"/>  
                            <p:column >
                                Base Ac. #: #{p.account.accountNumber}<br/>
                                Company Name: #{p.company}<br/>First Name:#{p.firstName}<br/><strong>Last Name:#{p.lastName}</strong>
                            </p:column>
                        </p:selectOneMenu> 

                        <h:outputText value="Sample Type:"/>
                        <p:selectOneMenu id="sampleType" value="#{sampleExportController.search.sampleType}" effect="fade" >
                            <f:selectItem itemLabel="Select One" itemValue="" />
                            <f:selectItems value="#{sampleExportController.sampleTypes}" var="stype" itemLabel="#{stype}" itemValue="#{stype}"/>
                        </p:selectOneMenu>

                        <p:outputLabel for="acGro" value="Grower"/>
                        <p:selectOneMenu id="acGro" value="#{sampleExportController.search.grower}"  
                                         panelStyle="width:150px" effect="fade" var="p" style="width:160px"  
                                         filter="true" filterMatchMode="contains" >  
                            <f:selectItem itemLabel="Select One" itemValue="" />  
                            <f:selectItems value="#{sampleExportController.growers}" var="grower" itemLabel="#{grower}" itemValue="#{grower}"/>

                        </p:selectOneMenu>

                    </h:panelGrid>
                    <p:commandButton update=":mainForm:DTsamplesVw" process="innerSearch" icon="ui-icon-search" value="Search" actionListener="#{sampleExportController.loadSearch}" oncomplete="searchDialog.hide()"/>

            </p:dialog>
            </h:form>
            <p:dialog id="viewerID" widgetVar="viewerDialog" modal="true" dynamic="true" hideEffect="puff" showEffect="puff"  appendToBody="false"
                      maximizable="true" header="Viewing selected samples" rendered="#{sampleExportController.allowReading eq true}">
                <h:form id="innerView">   
                    <h:panelGrid columns="2" width="100%">
                        <h:panelGrid>
                            <p:panelGrid >
                                <f:facet name="header">  
                                    <p:row>
                                        <p:column colspan="1" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">
                                            CSV Single Sample Report 
                                        </p:column>
                                        <p:column colspan="1" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">
                                            Single Sample Report Export  
                                        </p:column>
                                        <p:column colspan="1">
                                            Lab Number Report Export
                                        </p:column>
                                    </p:row>
                                </f:facet>  
                                <p:row>
                                    <p:column style="text-align: center;" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">
                                        <p:commandLink ajax="false" id="cOnecsv" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateSingleSampleReportCSV}" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">  
                                            <p:fileDownload value="#{sampleExportController.file}" />  
                                            <p:graphicImage value="./resources/images/csv.png" alt="Download the report by sample as a PDF."/>  
                                        </p:commandLink> 
                                        <p:tooltip for="cOnecsv" value="Download the report by sample as a CSV." showEffect="fade" hideEffect="fade" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}"/> 
                                    </p:column>
                                    <p:column style="text-align: center;" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">
                                        <p:commandLink ajax="false" id="cOnePdf" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateSingleSampleReportPDF}" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}">  
                                            <p:fileDownload value="#{sampleExportController.file}" />  
                                            <p:graphicImage value="./resources/images/pdf.png" alt="Download the report by sample as a PDF."/>  
                                        </p:commandLink> 
                                        <p:tooltip for="cOnePdf" value="Download the report by sample as a PDF." showEffect="fade" hideEffect="fade" rendered="#{sampleExportController.selectedSample.sampleType eq 'Soil'}"/> 
                                    </p:column>
                                    <p:column style="text-align: center;">
                                        <p:commandLink ajax="false" id="cMultiPdf" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{sampleExportController.generateMultiSampleReportPDF}">  
                                            <p:fileDownload value="#{sampleExportController.file}" />  
                                            <p:graphicImage value="./resources/images/pdf.png" alt="Download the report by lab Number as a PDF."/>  
                                        </p:commandLink> 
                                        <p:tooltip for="cOnePdf" value="Download the report by lab Number as a PDF." showEffect="fade" hideEffect="fade" /> 
                                    </p:column>
                                </p:row>
                            </p:panelGrid>

+ random ending tags

共有1个答案

栾昂雄
2023-03-14

问题出在您的对话框中。有p:commandButton包含以下内容:

<p:commandButton update=":mainForm:DTsamplesVw" process="innerSearch" 
    icon="ui-icon-search" value="Search" 
    actionListener="#{sampleExportController.loadSearch}" 
    oncomplete="searchDialog.hide()"/>`

它应该是update=“:mainForm:DTsamples”,因为您需要引用id而不是widgetVar。祝您有个美好的一天!

 类似资料:
  • 在整个评估过程中使用JxBrowser,效果非常好。现在,我一启动它就突然不起作用了。我在Mac OS X 10.11上运行,但我也在Windows上测试过,仍然不起作用。我的构建路径中有两个操作系统所需的库。这就是我得到的(在Mac OS X上运行):

  • 我很难在服务器重新引导时重新启动pm2(它本身和两个节点/express文件,&)。 下面是我尝试的过程: 我在所有可能的组合中运行了上面的命令,但没有任何工作。我试着以根用户的身份运行,但也不起作用。 我的文件包含信息,所以我不知道还可以在哪里查找。 我尝试的其他参考资料... http://pm2.keymetrics.io/docs/usage/startup/ https://www.di

  • 经过一番努力,我最终成功地在伪分布式节点中使用了hadoop,和工作正常(和) 昨天,我尝试用以下方法重新启动、等: 给出以下输出: Namenode似乎不愿意再启动了...几秒钟后Jobtracker就死了。 mapred-site.xml:

  • 我最近安装了Netbeans 7.2测试版,效果很好。然后,我在beta版的基础上安装了Netbeans 7.2最终版本,在安装过程中,Netbeans 7.1和Netbeans 7.12都在那里。现在,当我启动Netbeans时,它并没有超出“加载模块”阶段。只需在启动几秒钟后,Netbeans屏幕就会消失。然后我做了以下事情。 卸载所有Netbean版本并重新安装Netbean 7.2 已删除

  • krish@krish-virtualbox:~$start-dfs.sh 14/10/20 13:16:16警告util.nativeCodeLoader:无法为您的平台加载本机Hadoop库...在适用的情况下使用内置Java类 正在[localhost]上启动名称代码 我只想知道在里面所有的东西是不是都很完美。我在清单中没有看到Datanode。

  • 我是storm的新手,当我提交拓扑主管日志时 配置是 zookeeper的版本为 结果喷口不能发出消息和螺栓也有什么我可以分享它来解决这个问题吗?谁能帮忙?!