Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:55:15+00:00 2026-06-17T05:55:15+00:00

I have a jsf page called tours, and a tourController, in tours I use

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:55:16+00:00Added an answer on June 17, 2026 at 5:55 am

    Update:
    OP solved it by himself :

    This post helped Primefaces DataGrid – CommandLink is not working.<p:panel> tags should be inside <p:column> when all are inside a <p:datagrid> tag.


    So the things I would check if I were you :

    I suppose viewTour() get correctly called and executed.

    • Check if ViewTour.xhtml is in the same folder as tours.xhtml. If not you have to specify the correct path.
    • Check if your servlet mapping is correctly configured for the .jsf files. Open your web.xml located in configuration files and check if servlet mapping looks like this:

    <servlet-mapping>

        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
     </servlet-mapping>
    

    There can be many other problems but these are IMO the most frequent..

    Also NOTE:

    If you need to update the URL adress in the browser then you need to use redirect.

    To redirect to another page you have to use ?faces-redirect=true. Append it to your return string like this return "ViewTour?faces-redirect=true";. Without this you are using only forward mechanism which is happening completely on the server side so your URL won’t get updated in the browser.

    Edit

    The reason why it is not navigating in your case may be the bean scope of your tourController bean. Since controller beans are in the most cases @RequestScope-d (I assume it is your case as well) the problem is that your <h:commandLink> is placed inside iterating component – <p:dataGrid>. JSF will try to find clicked commandLink and submited values during the apply request values phase – it will reiterate over the component.

    Beacause of that you need to ensure that exactly the same value of the component has been given during this phase (as when it was clicked).

    Solution: Put your bean to @ViewScope or load data in @PostConstruct.

    Also to check for the other relevant issues see this post by JSF guru BalusC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF page that displays a table from an object called TableQuery
I have a page called index.xhtml , in which I use variables from a
i have a page called page1.jsf which contains one parameter. i have a command
I have a (JSF 2.0/ Primefaces 2.2RC-SNAPSHOT) app that has <p:layout> I use a
I have a basic JSF page called Index.xhtml and a backing bean called TestBean.java.
I have a JSF page where I want to show a image. The image
I have: A managed bean called LoginBean. A JSF page called login.xhtml In this
Suppose i have JSF page <h:body> <h:form id=formID prependId=false> <h:outputText id=randomID value=#{randomNumber.random}/> <h:commandButton id=buttonID
I have a JSF page that is included in other JSF pages (basically a
i have a jsf page which displays an image from an url http://ichart.finance.yahoo.com/z?s=^NSEI&t=1d&q=l&l=on&z=l&p=s&a=v&p=s i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.