当我尝试从模式调用支持 bean 方法时,它仅在我第二次单击时调用该方法。我尝试使用“action=''”和“onclick=''”调用该方法。问题是,1)我必须单击两次才能调用该方法 2)当我在“oncomplete”上添加一个javascript函数时,模态窗口关闭,但没有调用该方法。第一次单击该按钮时,我收到警告:找不到资源 /userarea/true.xhtml。userarea 是我的 JSF 页面所在的文件夹。
<?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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:b="http://bootsfaces.net/ui"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="../WEB-INF/templates/template-main.xhtml">
<ui:define name="title">Team</ui:define>
<ui:define name="content">
<f:metadata>
<f:viewAction action="#{TeamBacking.currentUserIsMemberOfATeam()}" />
<f:viewAction action="#{TeamBacking.onPageLoad()}" />
</f:metadata>
<b:row>
<b:column span="7">
<!--Rendered in case there is a team-->
<b:panel rendered="#{TeamBacking.currentUserIsMemberOfATeam()}"
title="Team"
collapsible="false">
<h1>#{TeamBacking.teamName}</h1>
<b:dataTable value="#{TeamBacking.team.students}"
var="teamMember"
id="team-members"
styleClass="table table-striped table-bordered">
<h:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{teamMember.firstName} #{teamMember.lastName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Benutzername" />
</f:facet>
<h:outputText value="#{teamMember.username}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Aktion" />
</f:facet>
<h:form>
<b:commandButton look="danger"
size="small"
value="Entfernen"
onclick="ajax:TeamBacking.setSelectedUser(teamMember);"
oncomplete="javascript:$('.delete-user-pseudo').modal();return false;"
update="delete-user-modal">
</b:commandButton>
</h:form>
</h:column>
</b:dataTable>
<h:outputText rendered="#{TeamBacking.team.project != null}" escape="false">
<p>Projekt: #{TeamBacking.team.project.projectName}</p>
</h:outputText>
</b:panel>
</b:column>
</b:row>
<b:modal id="delete-user-modal"
closable="true"
title="Teammitglied entfernen"
styleClass="delete-user-pseudo" >
<p>Folgenden Nutzer aus dem Team entfernen?</p>
<ul>
<li>Name: #{TeamBacking.selectedUser.firstName} #{TeamBacking.selectedUser.lastName}</li>
<li>Menutzername: #{TeamBacking.selectedUser.username}</li>
</ul>
<h:form id="delete-user-form">
<b:commandButton look="warning"
value="Abbrechen"
onclick="javascript:$('.delete-user-pseudo').modal('hide');return false;" />
<b:commandButton look="danger"
value="Löschen"
onclick="ajax:TeamBacking.deleteSelectedUserFromTeam()"
oncomplete="javascript:$('.delete-user-pseudo').modal('hide');return false;"
update="team-members" />
</h:form>
</b:modal>
</ui:define>
</ui:composition>
</html>
现在我还尝试删除模式,以便按钮位于“空白页面”内并一直呈现如下所示。按钮仍然仅在第二次单击时调用支持 bean 方法。任何想法可能是什么问题?
<b:row id="delete-user-modal"
styleClass="delete-user-pseudo" >
<b:column span="12">
<p>Folgenden Nutzer aus dem Team entfernen?</p>
<ul>
<li>Name: #{TeamBacking.selectedUser.firstName} #{TeamBacking.selectedUser.lastName}</li>
<li>Menutzername: #{TeamBacking.selectedUser.username}</li>
</ul>
<h:form id="delete-user-form">
<b:row>
<b:column span="4" />
<b:column span="4">
<b:commandButton look="warning"
value="Abbrechen"
styleClass="full-width"
iconAwesome="stop-circle"
onclick="javascript:$('.delete-user-pseudo').modal('hide');return false;" />
</b:column>
<b:column span="4" >
<b:commandButton look="danger"
value="Löschen"
onclick="ajax:TeamBacking.deleteSelectedUserFromTeam()"
update="team-members form-picklist"
styleClass="full-width"
iconAwesome="trash-o"/>
</b:column>
</b:row>
</h:form>
</b:column>
</b:row>