2

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

<?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>

这是我使用它的方式:

<aym:onayButon id="onay2" label="#{lbl.kaydet}" 
    actionMethod="#{userMB.addUser}" pupupId="onaylaPopup" 
    message="#{msg.onay_sonuc}"  />

我正在传递单击按钮时要调用的操作方法。但是,当我这样做时,我会得到PropertyNotFoundException

WARNING: #{actionMethod}: javax.el.PropertyNotFoundException: /WEB-INF/tags/com/components/onayButton.xhtml @29,33 action="#{actionMethod}": /pages/index.xhtml @33,48 actionMethod="#{userMB.addUser}": Property 'addUser' not found on type com.otv.managed.bean.UserManagedBean
javax.faces.FacesException: #{actionMethod}: javax.el.PropertyNotFoundException: /WEB-INF/tags/com/components/onayButton.xhtml @29,33 action="#{actionMethod}": /pages/index.xhtml @33,48 actionMethod="#{userMB.addUser}": Property 'addUser' not found on type com.otv.managed.bean.UserManagedBean
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)

当我像这样对标记文件中的操作方法进行硬编码时,它工作正常:

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

这是如何引起的,我该如何解决?

4

1 回答 1

1

尝试将操作 bean 和操作方法作为两个单独的参数作为解决方法:

模板

<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}"  />

在调用时,bean 需要放在大括号中,方法名称仅以字符串形式给出。另请参阅有关类似主题的解决方案

也许它有帮助...

于 2013-12-16T15:36:19.717 回答