wood burning stoves
The moose likes JBoss/WildFly and the fly likes SEAM accessing clicked link's object on next page (SOLVED) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "SEAM accessing clicked link Watch "SEAM accessing clicked link New topic

SEAM accessing clicked link's object on next page (SOLVED)

Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
I have a page on which few hyperlinks are displayed. It's code is pasted below:

As you can see above, each hyperlink belongs to a java object whose class has name 'screen' under SEAM. Here's Screen class's code

My question is, when user clicks a hyperlink, how can I access corresponding screen object on next page. I am trying following on next page:

But I get nothing within second <h2> and </h2>. How do I access clicked link's object? Is it a scope thing for Screen class? I have tried Session and Event but to no use.

-Varun -
(My Blog) - Online Certifications - Webner Solutions
Vivek Murugesan

Joined: Apr 09, 2009
Posts: 9
<hutputLink value="#{screen.url}">
<hutputText value="#{screen.label}"/>
<f:param name="url" value="#{screen.url}" />
<hutputText value="#{screen.definition}"/>

In pages.xml, you can track it (event context)

<page view-id="/XXXXX.xhtml">
<param name="url"/>

Hope this helps!!
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Thanks Vivek, unfortunately that will not solve the problem.
I need whole screen object on next page, not url parameter only. I pasted simplified (next page) code to communicate requirement.
There must be a way in SEAM to propagate selected/clicked object to next page, I wonder if that has anything to do with its conversation scope.
Anybody to help please?
Ryan Waggoner
Ranch Hand

Joined: Jun 27, 2007
Posts: 75
Here is how I do things with Seam, for cases like this.

First I create a SF bean. In this bean I would put your list of Screen objects, and an instance of the Screen (to select a specific one)

You can look up the annotations here.

Than a method to select the current screen, which you will call with your links...

So now if we change the first JSP a little bit..

So now the screenList is in the bean we just made as a list of screens (you'll have to populate it)
When you select a screen from your list, the DatamodelSelection annotation makes it really easy for us, and will automatically map the screen you clicked to the screen in the bean. Now you have that bean in the conversation and you can do whatever you want with it, before you end the conversation.

Let me know if that helped...I am still new to Seam myself...
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Thanks Ryan for your help. I tried similar code earlier, but was not able to make that work. I am sure it will work and I was missing something (I was using ScopeType.Conversation for Screen object, not for the SB used to populate screen objects).

But good thing is problem is solved now with a very small change. I am still using ScopeType.EVENT for Screen object. Only thing changed is view file. Instead of using h: outputLink tag I am now using s: link with view attribute. Earlier I had tried s: link with action element and I was confused as to how to provide a JSP/JSF file to action which was supposed to call a method. I was not paying attention to view attribute of s: link. See the code below, it works and gives me selected screen object on next page:

I agree. Here's the link: http://aspose.com/file-tools
subject: SEAM accessing clicked link's object on next page (SOLVED)
It's not a secret anymore!