Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

I'm trying to find a solution to what used to be a very simple problem, in the days of the Jsp.

My problem is this: I'm using Seam 2.1.2 and JSF R.I. 1.2_12, under tomcat 6.

I have a search page where the user selects it's criterion, then it press Search button, then it gets the result IN ANOTHER PAGE.

Now all my problem is passing the result of the search (a list of objects) to the second page (during the same request). The first page calculates the list, then pass it to the second page for rendering. Just like the servlets use to pass data to the jsp.

First thing tried, outject the list in the event context, and inject it to the second page

The second page gets nothing, it seems the event context is not kept.

Second thing, using FacesContext.getExternalContext().getRequestMap (), which is backed by the ServletRequest.getAttribute()/ServletRequest.setAttribute() that was used by Jsps.

Still nothing for the second page, request attributes seems to be cleared too.

Of course, If I switch to Conversation context, everything works, and the second page get its result list. But I don't want to keep this list in memory more than needed, so I don't want to use Conversation or Session context for that.

My question is: Without writing complex code, is there any simple way to do this ?

GC.

5 comments:
 
01. Mar 2010, 10:28 America/New_York | Link
Dany

I'm struggling with the same issue. The object I'm trying to pass is relatively small, it only has 7 primitive type attributes. So I could probably pass them as request parameters using 7

<param>

tags inside the s:link tag. But I would prefer to find out how I could pass an entire object in one shot.

 
02. Mar 2010, 16:41 America/New_York | Link

It should work I guess. Are you sure you have a render directive in your navigation flow and not a redirect ?

 
08. Mar 2010, 12:41 America/New_York | Link

You're right.

I was using redirect and not render ! With render, the event context is now working like I wanted too. I mean, it can be used to pass objects between pages.

There are some changes in using render - The url in the browser stays the same, so no reload is possible - But I guess I can manage it.

Thanks alot for your answer !

GC.

 
20. Apr 2010, 13:17 America/New_York | Link
Hero
Maybe the following Standard-JSF Tags will help you:

<h:commandButton value="Add to Basket" rendered="#{product.availableItems>0}">
       <f:setPropertyActionListener target="#{Basket.selectedProduct}" value="#{product}" />
</h:commandButton>

the called method looks like this:

   public void setSelectedProduct(Product p)
    {
        p.decreaseItemnumber();
        this.addProduct(p);
    }
 
23. Jul 2010, 17:37 America/New_York | Link
Hi All,


I am also facing an issue to pass an object.


I have a search page in which user enters some criteria and click on search button it displays data in a datalist below the page. I have a column named action, value in this column is a link so when the user clicks on the link. I have to open a new page in which user can do a new process.(Assume that the list is products list and action link is New Purchase). So when user clicks on New Purchase page should display with values from the row in table. I don’t have id for product and I also can't do a search in wire () method of purchase action because my search criteria contains some 12-15 fields and 14 tables so it may take more time.

I think I need the pass the product object to Purchase action.

What I did I created a method say Xyz(Object obj) in Purchase action and called it in the New Purchase link(action=#{purchaseAction.Xyz(_product)}). But obj is null in purchase action.

Can anyone suggest what the best approach is?

Thanks in Advance