0
votes

I have implement the datatable lazy (http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml), it works fine.

Now I want to open a new page when a row is selected. For example, I have to do this :http://primefaces-rocks.appspot.com/ui/datatableRowSelectionInstant.jsf (the second table).

In my LazyView class, I tried :

try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("carDetails.xhtml?id=" + ((Car) event.getObject()).getId().toString());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

The carDetail page is showing but values are empty. I don't know how I can get the value of the car in the carDetail.xhtml page...

I also try this code :

public String onRowSelectNavigate(SelectEvent event) {  
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedCar", event.getObject());  

        return "carDetail?faces-redirect=true";  
    }

But it doesn't work.

Can someone help me?

Thank's

2
I suppose you just need a viewParam and a viewAction in the target-page, for example described under "Processing GET request parameters" here: balusc.blogspot.com/2011/09/communication-in-jsf-20.html - Jaqen H'ghar
What is the Scope of your ManagedBean? - rion18
the scope of my LazyView is ViewScoped, why? - Pierre

2 Answers

0
votes

On your bean, you need to create a parameter, in that you can set the id of the for this case. So, when you select a row in your datatable, with a button for example, you can add a setter of that property.

<h:commandButton action="#{bean.showNewPage}" value="Submit">
    <f:setPropertyActionListener target="#{bean.carId}" value="result.carId" />
</h:commandButton>
0
votes

The reason was : SessionScoped in my view class :)

thank you