[jboss-user] [JBoss Seam] - Problem with DataModel and s:link
vfaid
do-not-reply at jboss.com
Tue Nov 20 09:47:00 EST 2007
Hello,
I'm using Seam 2.0GA.
I've a rich:dataTable that displays the values of a DataModel outjected from a "search" component. Each row defines a s:link with an action that triggers the call to a select method of an "info" component throuh a pageflow. The two components are in a the same conversation scope.
It works fine if I use h:commandLink or h:commandButton but if i use s:link, it fails. The value passed to the select method is always the one that's attached to first row I've clicked.
Here are the code snippets.
SearchBookingAction:
| @Stateful
| @Scope(ScopeType.CONVERSATION)
| @Name("search")
| @Restrict("#{identity.loggedIn}")
| public class SearchBookingAction implements SearchBooking {
|
| @In
| private EntityManager arsEntityManager;
|
| @DataModel
| private List<Booking> bookings;
|
| private String pnr;
| private String flightNumber;
| private Date flightDate;
|
| public void search()
| {
| Query query = arsEntityManager.createQuery(...);
| bookings = query.getResultList();
| }
|
| ....
| }
|
BookingInfoAction:
| @Stateful
| @Scope(ScopeType.CONVERSATION)
| @Name("info")
| public class BookingInfoAction implements BookingInfo {
|
| @In
| private EntityManager arsEntityManager;
|
| private Booking booking;
|
| private List<Flight> departureFlights;
| private List<Flight> returnFlights;
|
| public void selectBooking(Booking booking) {
| this.booking = booking;
| }
|
| public boolean populate() {
| log.info("info.populate() called with: "+booking.getPnr());
| if (booking == null)
| return false;
| departureFlights = selectDepartureFlights();
| returnFlights = selectDepartureFlights();
| return true;
| }
|
| ...
| }
|
search.xhtml:
| <rich:dataTable value="#{bookings}" var="currentBooking" >
| <rich:column>
| <f:facet name="header">#{messages['asr.list.pnr']}</f:facet>
| #{currentBooking.pnr}
| </rich:column>
| <rich:column>
| <f:facet name="header">#{messages['asr.list.name']}</f:facet>
| #{currentBooking.masterName}
| </rich:column>
| <rich:column>
| <f:facet name="header">#{messages['asr.list.flightnum']}</f:facet>
| #{currentBooking.masterFlightNumber}
| </rich:column>
| ...
| <rich:column>
| <f:facet name="header">#{messages['asr.list.viewheader']} :</f:facet>
| <s:link value="#{messages['asr.list.view']}" action="view" />
| </rich:column>
| </rich:dataTable>
|
bo.jpdl.xml:
| <start-page name="displaySearchBookingForm" view-id="/search.xhtml">
| <redirect/>
| ...
| <transition name="view" to="populateBookingInfo">
| <action expression="#{info.selectBooking(currentBooking)}" />
| </transition>
| </start-page>
|
| <decision name="populateBookingInfo" expression="#{info.populate()}">
| <transition name="true" to="displayBooking"/>
| <transition name="false" to="displayFindBookingForm"/>
| </decision>
|
| <page name="displayBooking" view-id="/booking.xhtml" back="enabled">
| <redirect/>
| ...
| </page>
|
| ...
|
Any ideas why it works with a h:commandButton or h:commandLink and not a s:link?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106404#4106404
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106404
More information about the jboss-user
mailing list