问题描述
我想prevent刷新页面,当用户点击< H:commandLink>
在我的一个应用。我试过,但它不工作:
I am trying to prevent a page refresh when the user clicks on <h:commandLink>
in my applicaton. I tried this but it does not work:
更新:
<h:dataTable value="#{person.IssueList}" var="p" >
<h:column style="width: 20px">
<f:facet name="header">Issue</f:facet>
<h:commandLink value="#{p.IssueDesc}"/>
</h:column>
<h:column style="width: 20px">
<f:facet name="header">Reporting Date</f:facet>
<p:calendar value="#{p.issuerepDt}" rendered="#{p.editable}" id="CalendarId"/>
<h:outputText value="#{p.issuerepDt}" rendered="#{not p.editable}" />
</h:column>
<h:column>
<f:facet name="header">Action</f:facet>
<h:commandLink value="Edit" action="#{person.editAction(p)}">
<f:ajax execute="@form" render="@none" />
</h:commandLink>
</h:column>
</h:dataTable>
Java代码片段:
java snippet :
public void editAction(PersonIssues pIssues) {
pIssues.setEditable(true);
}
我使用编辑JSF DataTable的概念从MKyong.I
I am using concept of editing jsf datatable from MKyong.I
推荐答案
由于我看到你的使用primefaces日历组件,您可能需要使用primefaces命令和数据表,以及。该primefaces组件都扮演pretty的漂亮起来。
Since i see your using primefaces for the calendar component, you may want to use the primefaces commandbutton and datatable as well. The primefaces components all play pretty nice together.
从我下面的例子中,你可以看到我给你的数据表中的ID和在commandLink,我已经添加了一个更新的属性来更新数据表的操作被调用后。默认情况下,primefaces有一个设置为true的commandLinks一个ajax属性。
From my example below, you can see that i gave your datatable an id and on the commandLink, i've added an update attribute to update the datatable after the action is called. By default, primefaces has an ajax attribute that is set to true on the commandLinks.
<p:dataTable id="myTable" value="#{person.IssueList}" var="p" >
<p:column style="width: 20px" headerText="Issue">
<p:commandLink value="#{p.IssueDesc}"/>
</p:column>
<p:column style="width: 20px" headerText="Reporting Date">
<p:calendar value="#{p.issuerepDt}" rendered="#{p.editable}" id="CalendarId"/>
<h:outputText value="#{p.issuerepDt}" rendered="#{not p.editable}" />
</p:column>
<p:column headerText="Action">
<p:commandLink value="Edit" action="#{person.editAction(p)}" update="myTable"/>
</p:column>
</p:dataTable>
这篇关于我怎样才能在点击了&LT prevent刷新页面; H:commandLInk&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!