I have a jsf page called tours, and a tourController, in tours I use a primefaces datagrid to show my tour items, and I use a commandLink to add a view link to each item. The problem is when I click the link, instead of going to viewTour page it shows the same page of tours.xhtml. And after a while it says view expired, so it seems that it goes somewhere. Here is my code:
TourController.java viewTour method:
public String viewTour(){
current = (Tour) getItems().getRowData();
selectedItemIndex = pagination.getPageFirstItem()+getItems().getRowIndex();
return "ViewTour";
}
tours.xhtml datagrid:
<h:form id="list">
<p:dataGrid var="item" value="#{tourController.items}" columns="4" rows="20" paginator="true">
<p:panel>
<p:panelGrid style="width: 180px; height: 200px">
<f:facet name="header">
<p:row><p:column colspan="2"><h:outputText value="#{item.destination}"/></p:column></p:row>
</f:facet>
<p:row>
<p:column colspan="2" style="text-align: center">
<h:commandLink id="viewTour" action="#{tourController.viewTour()}" style="color: darkred; font-weight: bold">
<h:outputText value="#{item.description}"/>
</h:commandLink>
</p:column>
</p:row>
<p:row>
<p:column rowspan="2" style="vertical-align: middle">
<h:outputText value="#{item.company}"/><br/>
<h:outputText value="#{item.phone}"/><br/>
<a href="mailto:#{item.email}"><h:outputText value="#{item.email}"/></a><br/>
<a href="#{item.websiteurl}"><h:outputText value="#{item.websiteurl}"/></a>
</p:column>
</p:row>
<p:row>
<p:column><p:graphicImage value="/resources/images/tours/#{item.imgurl}.jpg"/></p:column>
</p:row>
</p:panelGrid>
</p:panel>
</p:dataGrid>
</h:form>
ViewTour.xhtml:
<h:form>
<h:panelGrid columns="2">
<h:outputText value="#{bundle.ViewTourLabel_imgurl}"/>
<h:outputText value="#{tourController.selected.imgurl}"/>
<h:outputText value="#{bundle.ViewTourLabel_source}"/>
<h:outputText value="#{tourController.selected.source}" title="Source"/>
<h:outputText value="#{bundle.ViewTourLabel_destination}"/>
<h:outputText value="#{tourController.selected.destination}" title="Destination"/>
<h:outputText value="#{bundle.ViewTourLabel_daysno}"/>
<h:outputText value="#{tourController.selected.daysno}" title="Duration"/>
<h:outputText value="#{bundle.ViewTourLabel_price}"/>
<h:outputText value="#{tourController.selected.price}" title="Price"/>
<h:outputText value="#{bundle.ViewTourLabel_description}"/>
<h:outputText value="#{tourController.selected.description}" title="Description"/>
<h:outputText value="#{bundle.ViewTourLabel_date}"/>
<h:outputText value="#{tourController.selected.date}" title="Date of Travel:">
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:outputText>
<h:outputText value="To book this trip contact:"/>
<h:outputText value="#{bundle.ViewTourLabel_phone}"/>
<h:outputText value="#{tourController.selected.phone}" title="Phone:"/>
<h:outputText value="#{bundle.ViewTourLabel_email}"/>
<h:outputText value="#{tourController.selected.email}" title="Email:"/>
<h:outputText value="#{bundle.ViewTourLabel_purpose}"/>
<h:outputText value="#{tourController.selected.purpose}" title="Special Purpose Tour:"/>
<h:outputText value="#{bundle.ViewTourLabel_company}"/>
<h:outputText value="#{tourController.selected.company}" title="Arranged by:"/>
<h:outputText value="#{bundle.ViewTourLabel_websiteurl}"/>
<h:outputText value="#{tourController.selected.websiteurl}" title="Website:"/>
<h:outputText value="#{bundle.ViewTourLabel_rating}"/>
<h:outputText value="#{tourController.selected.rating}"/>
</h:panelGrid>
</h:form>