tags:

views:

2071

answers:

2

Hello,

I'm using JSF/ICEFaces. I have a table that have many rows with values and I have another page that displays charts. I want to have an icon on every row to chart that specific combo. I know to do regular navigation with JSF by returning a string navigation rule. However, I'm not sure how to pass parameters from the bean corresponding to the row to the bean that does the charting. Do you know I can approach that problem?

Thanks,

Tam

+1  A: 

So you have Page A with the table of stuff and Page B with charts of individual stuffs. Flow being: Navigate to Page A -> Look through the table -> Click something on Page A to look at charts -> Navigate to Page B -> Read Charts.

There are a couple of different things you can do here. I will suggest three.

One, you can make the chart page RESTful and pass in the ID of the stuff you're going to chart. IE, a column on your page would have:

<ice:outputLink value="/chartPage?stuffID=#{iterator.stuffID}">Review Chart</ice:outputLink>

Then in your chart page's backing bean you can either use JAX-RS to pass in the page parameter or you can dredge the request object, ie:

(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("stuffID)

You can use that to get the StuffID and build your chart. This achieves a good separation of concerns, letting your charting page just do charting without having to worry about what beans it will be getting the charts from. This is the way I would personally do this.

Two, you can simply make your bean session scoped (or, conversation scoped if you're using Seam or similar) so that the two pages simply share the one bean. This is probably the simplest but you will need to ensure that the bean is cleaned up when you no longer need it and thus, somewhat dangerous.

Three, you can use a regular HTTP form and POST to the charting page, using the same kind of RequestParameterMap dredging that you did for number one. This works the same way as number one but isn't quite as clean as you will need a similar form everywhere you want to do this and it cannot be a normal hyperlink.

Those three would accomplish what you need though, again, my recommendation would be number one. Being able to link to the charting page with just a regular hyperlink would probably be pretty handy.

Drew
A: 

Hi, and how to pass an Object instead of a String?