Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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 setpropertyactionlistener_Jsf_Jsf 2_Primefaces - Fatal编程技术网

未调用JSF setpropertyactionlistener

未调用JSF setpropertyactionlistener,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我在数据表中有一个f:setPropertyActionListener,单击命令按钮,setpropertyaction listener将不会被调用。有人知道我哪里出错了吗 谢谢 <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://jav

我在数据表中有一个f:setPropertyActionListener,单击命令按钮,setpropertyaction listener将不会被调用。有人知道我哪里出错了吗

谢谢

 <?xml version="1.0" encoding="UTF-8"?>
<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:form id="userDetailsForm" style="padding:5px"> 
        <p:growl id="messages" showDetail="true" autoUpdate="true" life="2000"/>
        <p:spacer height="15"></p:spacer>

    <div class="row">     
      <div class="col-lg-4">
        <div class="input-group">
          <p:inputText type="text" styleClass="form-control" value="#{emailArticleBean.searchText}" />
          <span class="input-group-btn" style="margin:3px;">
            <p:commandButton actionListener="#{emailArticleBean.search}" value="Go!" update=":userDetailsForm:emailArticleTable" />
          </span>
        </div><!-- /input-group -->
      </div><!-- /.col-lg-6 -->
    </div><!-- /.row -->

    <p:spacer height="15"></p:spacer>
    <h:messages/>

    <div class="row">
        <div class="col-lg-1">

        </div>
        <div class="col-lg-11">
        <p:dataTable var="email" value="#{emailArticleBean.emailArticles}" scrollRows="20"  
                    scrollable="true" liveScroll="true" scrollHeight="750" id="emailArticleTable" 
                    >
            <p:column>
                <p:accordionPanel multiple="true" activeIndex="-1" id="panel#{email.id}">  

                    <p:tab title="#{email.headline}" titleStyleClass="email-header">  
                           <div style="clear:both;margin-bottom:10px;">
                           <h6 style="font-weight:bold;">Summary</h6>
                            <h:outputText  
                                value="#{email.summary}" />     
                            </div>  
                            <div style="clear:both;margin-bottom:10px;">
                            <h6 style="font-weight:bold;">Implication</h6>
                            <h:outputText  
                                value="#{email.implication}" />     
                            </div>           
                            <div style="float:left;clear:both">
                                <p:commandButton  value="View Existing Actions" 
                                    oncomplete="PF('dlg2').show();" update=":userDetailsForm:emailActionDialog">
                                     <f:setPropertyActionListener value="#{email}" target="#{emailArticleBean.selectedEmail}" />  
                                </p:commandButton>                  
                             </div> 
                             <br/>
                             <br/>
                             <div style="margin-top:10px;">        
                                <h:inputTextarea id="accordian1" value="#{email.tempAction}" cols="90" rows="3" />                          
                            </div>
                            <h6 style="font-weight:bold;">Due Date</h6>  
                            <p:calendar value="#{email.tempDate}" id="popupCal" pattern="dd MMM, yyyy"/> 
                            <p:commandButton actionListener="#{emailArticleBean.updateAction}" value="Add Action" 
                                 style="margin-left:5px;">
                                <f:setPropertyActionListener value="#{email}" target="#{emailArticleBean.selectedEmail}" />
                            </p:commandButton> 

                    </p:tab>
                </p:accordionPanel>
            </p:column>
        </p:dataTable>
        </div>

    </div> 

    <p:dialog id="emailActionDialog" header="Email Actions" widgetVar="dlg2" modal="true" height="100">  
        <h3>Email Actions</h3>  
        <p:dataList value="#{emailArticleBean.selectedEmail.actions}" var="action" itemType="disc">  
            #{action.action} --- #{action.username}  
        </p:dataList>  
    </p:dialog> 



    </h:form>   



</html>

这里的主要问题是调用的顺序,首先调用
actionListener
f:setPropertyActionListener

要解决此问题,请将
actionListener
更改为
action
,并更新action方法以返回字符串

钮扣

您可以继续使用actionListener并将selectedEmail传递给它(不使用f:setPropertyActionListener)

钮扣

要进一步了解调用的顺序


No将属性设置为@this无效。当操作被禁止时,您会怎么做?因为您构建了ajax UI,并且只使用f:ajax侦听器?@mondjunge“操作被禁止”是什么意思?@hatemaliam操作通常会触发webflows中的转换,从而导致页面重新加载。此外,您不能将参数传递给尚未编写的bean。您需要特别为ajax调用编写它们。因此,在ajax调用中使用action是一个相当麻烦的问题,在大型项目中不太可行。
public EmailArticle getSelectedEmail() {
        return selectedEmail;
    }

    public void setSelectedEmail(EmailArticle selectedEmail) {

        this.selectedEmail = selectedEmail;

    }

public void updateAction(ActionEvent ae) {
        selectedEmail.getActions().add(new EmailActions(emailAction, "testUser", actionDueDate));
        selectedEmail.merge();

    }
   <p:commandButton action="#{emailArticleBean.updateAction}" 
                    value="Add Action"  style="margin-left:5px;">
           <f:setPropertyActionListener value="#{email}" 
              target="#  {emailArticleBean.selectedEmail}" />
   </p:commandButton> 
public String updateAction() {
    selectedEmail.getActions().add(new EmailActions(emailAction, "testUser", actionDueDate));
    selectedEmail.merge();
    return null;
}
<p:commandButton actionListener="#{emailArticleBean.updateAction(email)}" 
                 value="Add Action"  style="margin-left:5px;">
</p:commandButton>
public void updateAction(EmailArticle selectedEmail) {
    selectedEmail.getActions().add(new EmailActions(emailAction, "testUser", actionDueDate));
    selectedEmail.merge();
}