大家早上好,我有一个与 primfaces 控件有关的问题。我在 dataGrid 中放置了一个 commandLink,但 commandLink 没有进入 action 方法。我不知道为什么。所以你能帮我解决这个问题吗PLZ这是代码
<f:view>
<h:form>
<p:tabView style="width: 420px;">
<p:tab title="Events">
<p:dataGrid value="#{EventDataTable.model}" var="event"
paginator="true" rows="3" columns="1"
paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink}"
paginatorPosition="bottom"
styleClass="ui-datagrid-no-border"
>
<p:fieldset style="width:285px;height:150px" legend="#{event.eventDto.title}">
<table>
<tr>
<td rowspan="5">
<p:graphicImage value="#{event.image}" />
</td>
</tr>
<tr>
<td></td>
<td>
Title: <p:outputLabel id="title" value="#{event.eventDto.title}"/>
</td>
</tr>
<tr>
<td></td>
<td>
Date: <p:outputLabel id="date" value="#{event.eventDto.date}"/>
</td>
</tr>
<tr>
<td></td>
<td>
Content: <p:outputLabel id="desc" value="#{event.eventDto.content}"/>
</td>
</tr>
<tr>
<td></td>
<td>
<p:commandLink value="View More" actionListener="#{EventDataTable.doSomething()}" ajax="false"/>
</td>
</tr>
</table>
</p:fieldset>
</p:dataGrid>
</p:tab>
</f:view>
</h:form>
这豆
@ManagedBean(name="EventDataTable")
@RequestScoped
public class EventBean implements Serializable{
@PostConstruct
public void initial() {
try {
System.out.println("test init");
List<EventDto> eventDtos = event.findEventByUserId(2);
List<EventWrapper> eventWrappers = new EventConverter().convert(eventDtos);
model = new ListDataModel<EventWrapper>(eventWrappers);
System.out.println("the size=" + model.getRowCount());
} catch (ApplicationException ex) {
ex.printStackTrace();
}
}
public EventBean() {
}
public void doSomething() {
//Doing Redirection will be here
System.out.println("The selected number is " + model.getRowIndex()+"*****************************");
}
}