Jsf 2 如何将方法表达式传递到Facelets标记文件

Jsf 2 如何将方法表达式传递到Facelets标记文件,jsf-2,primefaces,facelets,tagfile,methodexpression,Jsf 2,Primefaces,Facelets,Tagfile,Methodexpression,我为带有命令按钮的确认对话框创建了标记文件: <?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"

我为带有命令按钮的确认对话框创建了标记文件:

<?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:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui" 
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:aym="http://aym.com/facelets"
    xmlns:rich="http://richfaces.org/rich"
>
    <h:body>
        <ui:composition>    
            <p:growl id="messages" />

            <h:panelGrid columns="1" cellpadding="5">   
                <p:commandButton value="#{label}" onclick="#{pupupId}.show()" type="button" ajax="false"/>
            </h:panelGrid>

            <p:confirmDialog message="#{message}"
                showEffect="bounce" hideEffect="explode"
                header="İşlem Onay" severity="alert" widgetVar="#{pupupId}">
                <p:commandButton value="Evet" update="messages" oncomplete="#{pupupId}.hide()" ajax="false"
                    action="#{actionMethod}" />
                <p:commandButton value="Hayır" onclick="#{pupupId}.hide()" type="button" /> 
            </p:confirmDialog>
        </ui:composition>
    </h:body>
</html>
当我在标记文件中硬编码action方法时,它可以正常工作,如下所示:

<p:commandButton ... action="#{userMB.addUser}" />


这是如何导致的,我如何解决它?

尝试将action bean和action method作为两个单独的参数:

模板

<p:commandButton value="Evet" 
    update="messages" oncomplete="#{pupupId}.hide()" ajax="false"
    action="#{actionBean[actionMethod]}" />

召唤


也许这会有帮助…

Hi@EmreAltun,给出的答案能进一步帮助您吗?感谢您的支持和兴趣,您为我提供的解决方案有效!
<p:commandButton ... action="#{userMB.addUser}" />
<p:commandButton value="Evet" 
    update="messages" oncomplete="#{pupupId}.hide()" ajax="false"
    action="#{actionBean[actionMethod]}" />
<aym:onayButon id="onay2" label="#{lbl.kaydet}" 
    actionBean="#{userMB}" actionMethod="addUser" pupupId="onaylaPopup" 
    message="#{msg.onay_sonuc}"  />