jsf上没有调用函数
我对A4J4函数有一些问题。我需要从dataTable中删除数据,getter和setter正在工作,弹出面板工作正常,但是没有调用该函数 请参阅此代码:jsf上没有调用函数,jsf,richfaces,ajax4jsf,Jsf,Richfaces,Ajax4jsf,我对A4J4函数有一些问题。我需要从dataTable中删除数据,getter和setter正在工作,弹出面板工作正常,但是没有调用该函数 请参阅此代码: <h:panelGrid id="panelGridDataT" style="margin-left:300px"> <h:form id="form" > <rich:dataTable style="margin-left:70px;h
<h:panelGrid id="panelGridDataT" style="margin-left:300px">
<h:form id="form" >
<rich:dataTable
style="margin-left:70px;height:200px; width:500px;overflow:auto"
value="#{ListSelectBean.listUser}" var="_tblUser" iterationStatusVar="it"
id="table" rows="5">
<rich:column>
<f:facet name="header">#</f:facet>
#{it.index}
</rich:column>
<rich:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{_tblUser.name}" />
</rich:column>
<rich:column>
<f:facet name="header">User Name</f:facet>
<h:outputText value="#{_tblUser.username}" />
</rich:column>
<rich:column>
<f:facet name="header">Role</f:facet>
<h:outputText value="#{_tblUser.roles}" />
</rich:column>
<rich:column style="width:40px">
<f:facet name="header">Delete</f:facet>
<a4j:commandLink style="padding:10px" execute="@this" render="@none" onclick="#{rich:component('confirmPane')}.show()">
<h:graphicImage value="/img/delete.gif" style="width:20px;height:20px" alt="delete" />
<!-- <a4j:param value="#{it.index}" assignTo="#{ListSelectBean.currentUserIndex}" />-->
<f:setPropertyActionListener target="#{ListSelectBean.deleteUser}" value="#{_tblUser}" />
</a4j:commandLink>
</rich:column>
<rich:column style="width:40px">
<f:facet name="header">Edit</f:facet>
<a4j:commandLink style="padding:10px" render="editGrid" action="#{ListSelectBean.asingEdit()}" execute="@this" onclick="#{rich:component('editPane')}.show() ">
<h:graphicImage value="/img/edit.gif" style="width:20px;height:20px" alt="edit" />
<a4j:param value="#{it.index}" assignTo="#{ListSelectBean.currentUserIndex}" />
<f:setPropertyActionListener target="#{ListSelectBean.editedUser}" value="#{_tblUser}" />
</a4j:commandLink>
</rich:column>
<f:facet name="footer">
<rich:dataScroller page="#{ListSelectBean.page}" style="margin-left:40px"/>
<h:commandButton value="Add New" id="Add" style="margin-left:40px" >
<rich:componentControl target="New_User" operation="show"/>
</h:commandButton>
</f:facet>
</rich:dataTable>
<a4j:jsFunction name="DeleteUser" id="DeleteUser" action="#{ListSelectBean.DeleteUser()}" render="@all" execute="@all"
/>
<rich:popupPanel id="confirmPane" autosized="true">
Are you sure you want to delete the row?
<a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" render="form" />
<a4j:commandButton value="Delete" onclick="DeleteUser();" oncomplete="#{rich:component('confirmPane')}.hide();">
<a4j:param value="#{it.index}" assignTo="#{ListSelectBean.currentUserIndex}" />
<f:ajax render="@all" execute="@all" />
</a4j:commandButton>
</rich:popupPanel>
<rich:popupPanel id="statPane" autosized="true">
<h:graphicImage value="/images/ai.gif" alt="ai" />
Please wait...
</rich:popupPanel>
<rich:popupPanel header="Edit User Details" id="editPane"
domElementAttachment="form" width="400" height="170">
<h:panelGrid columns="4" id="editGrid">
<h:outputText value="Name" />
<h:inputText value="#{ListSelectBean.nwname }" />
<h:outputText value="username" />
<h:inputText value="#{ListSelectBean.nwusername}" />
<h:outputText value="Pasword" />
<h:inputText value="#{ListSelectBean.nwpassword}" />
<h:outputText value="Email" />
<h:inputText value="#{ListSelectBean.nwemail}" />
</h:panelGrid>
<a4j:commandButton value="Store" action="#{ListSelectBean.storeUser}" render="table" execute="editPane"
style="position: absolute; right: 10px; bottom: 10px"
oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}" />
<a4j:commandButton value="Cancel" style="position: absolute; right: 60px; bottom: 10px"
onclick="#{rich:component('editPane')}.hide(); return false;" />
</rich:popupPanel>
</h:form>
</h:panelGrid>
有很多代码,我需要关注:
<rich:column style="width:40px">
<f:facet name="header">Delete</f:facet>
<a4j:commandLink style="padding:10px" execute="@this" render="@none" onclick="#{rich:component('confirmPane')}.show()">
<h:graphicImage value="/img/delete.gif" style="width:20px;height:20px" alt="delete" />
<!-- <a4j:param value="#{it.index}" assignTo="#{ListSelectBean.currentUserIndex}" />-->
<f:setPropertyActionListener target="#{ListSelectBean.deleteUser}" value="#{_tblUser}" />
</a4j:commandLink> </rich:column>
参数可以正常工作,但下一步不行:
<a4j:jsFunction name="DeleteUser" id="DeleteUser" action="#{ListSelectBean.DeleteUser()}" render="@all" execute="@all"
/>
<rich:popupPanel id="confirmPane" autosized="true">
Are you sure you want to delete the row?
<a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" render="form" />
<a4j:commandButton value="Delete" onclick="DeleteUser();" oncomplete="#{rich:component('confirmPane')}.hide();">
<a4j:param value="#{it.index}" assignTo="#{ListSelectBean.currentUserIndex}" />
<f:ajax render="@all" execute="@all" />
</a4j:commandButton>
</rich:popupPanel>
如果有人需要,Ihis就是bean:
private TblUser editedUser;
private TblUser deleteUser;
private int currentUserIndex;
private int UserRows;
private int page = 1;
private String Nwemail;
private String Nwname;
private String Nwpassword;
private String Nwroles;
private String Nwusername;
private String Nwtokenid;
private short Nwuserid;
private Long Nwuseroleid;
@DataModel
private List<TblUser> ListUser;
@DataModelSelection("ListUser")
@Out (required=false)
private TblUser selected;
@SuppressWarnings("unchecked")
@Factory(value="ListUser")
public List<TblUser> selectedList(){
ListUser = null;
if (ListUser == null){
try{
ListUser=entityManager.createQuery("select u from TblUser u").getResultList();
}catch(NoResultException e) {
System.out.print("Error"+e.getMessage());
}
}
return ListUser;
}
public void DeleteUser()
{
try{
entityManager.createQuery("Delete TblUser where userid = :userid")
.setParameter("userid", deleteUser.getUserid())
.executeUpdate();
//refreshPage();
}
catch (NoResultException e)
{
System.out.print("error: "+ e.getMessage());
}}
如果有人帮助我,我将不胜感激 您有TblUser deleteUser的getter和setter吗?是否可以检查deleteUser对象是否存在并且在deleteUser方法中是否正确?在a4j:jsFunction中,将action属性更改为action={ListSelectBean.deleteUser}。是否检查页面上是否定义了任何其他deleteUser javascript函数并尝试更改名称?a4j函数是否也在表单中?a4j:commandButton具有render属性。如果命令按钮仅用于呈现,则不需要f:ajax。@VasilLukach yes我有getter和setters public TblUser getDeleteUser{return deleteUser;}public void setDeleteUserTblUser deleteUser{this.deleteUser=deleteUser;}我更改操作={ListSelectBean.deleteUser}操作={ListSelectBean.deleteUser}而且不起作用。