[jboss-user] [JBoss Seam] - Re: Seam & Trinidad.

adamkoprowski do-not-reply at jboss.com
Sat Mar 10 19:50:02 EST 2007


  Dear Petemuir,
 Thank you for your fast and helpful response!

"petemuir" wrote : 
  | Part of the problem here is that Trinidad have taken ages to get a release out - once their 1.0.0 release is out (any day now I think) we can start improving Seam integration.
  | 

Great! Indeed it seems that the release is just around the corner so I'm looking forward for that! Then the stack of seam + facelets + ajax4jsf + Trinidad will be a killer!

anonymous wrote : 
  | "adamkoprowski" wrote : -) As I read on this forum (and experienced myself) I cannot use Seam's extended EL  (parameters to methods) with Trinidad.
  | 
  | I don't know of anyone who has got this working.
  | 
Too bad. Any idea what's the reason? Any hope this will be resolved at some point?

anonymous wrote : 
  | "adamkoprowski" wrote : -) As I'm dealing with Trinidad table @DataModel and @DataModelSelection won't work.
  | 
  | They *should* do - and I haven't heard anyone say they don't.  The current feeling is that page parameters are better than @DataModel stuff.  If they aren't working with Trinidad can you file a JIRA issue, and I'll try to take a look.
  | 
Ok, my fault, probably they do. I just recalled reading on this forum that @DataModel does not work for Trinidad trees and assumed that this is probably the case for tables as well.

anonymous wrote : 
  | "adamkoprowski" wrote : -) My second idea was to use the Seam pages.xml mechanism for request parameters propagation with the following navigation entry:
  |   | 
  |   |   | <page view-id="/master.xhtml">
  |   |   |   <navigation>
  |   |   |     <rule if-outcome="viewDetail">
  |   |   |       <redirect view-id="/detail.xhtml">
  |   |   |         <param name="id" value="#{master.selectedEntry.id}"/>
  |   |   |       </redirect>
  |   |   |     </rule>
  |   |   |   </navigation>
  |   |   | </page>
  |   |   | 
  |   |   But then in selectedEntry I need to figure out which table entry was clicked but for some reason the component tree has only AjaxViewRoot root component with no children. 
  |   |   Hence my questions: is it normal that the component tree is not available in this context? If not what may I be doing wrong? If so, how can I get the id of selected table entry?
  | 
  | I don't get *why* you need to do this.  Surely with the id of the selectedEntry you can load it from the persistence context and edit it?  Take a look at the way a seam-gen'd project does things - that demonstrates the use of page parameters for master/detail.
  | 
Ok, I guess I wasn't clear enough. What I meant is that I need to propagate the id to the detail page (and then surely I can fetch the data). Anyway I tried to take a look at how this is done by seam-gen (wasn't that easy for me as then the core of this master/detail navigation is obscured by many details). I tried to follow this approach and worked it out too a small but self contained and complete example showing the gist of my problem. There is still something I don't understand and I'd be very grateful if anybody could cast some light on me. Here we go:

Simple objects (Entry.java)

  | package test;
  | 
  | public class Entry
  | {
  | 	public Long id;
  | 	public String name;
  | 	
  |     public Entry(Long i)
  |     {
  |     	id = i;
  |     	name = "Entry #" + i;
  |     }
  | 
  | 	public Long getId()
  |     {
  |     	return id;
  |     }
  | 	
  |     public void setId(Long id)
  |     {
  |     	this.id = id;
  |     }
  | 	
  |     public String getName()
  |     {
  |     	return name;
  |     }
  | 	
  |     public void setName(String name)
  |     {
  |     	this.name = name;
  |     }
  | }
  | 

Master component (Master.java)

  | package test;
  | 
  | import java.util.List;
  | import java.util.Vector;
  | 
  | import org.jboss.seam.annotations.Name;
  | 
  | @Name("master")
  | public class Master
  | {
  | 
  | 	public List<Entry> getEntries()
  | 	{
  | 		List<Entry> res = new Vector<Entry>();
  | 		for (int i = 0; i < 50; i++)
  | 			res.add(new Entry(new Long(i)));
  | 		return res;
  | 	}
  | 	
  | }
  | 

Detail component (Detail.java)

  | package test;
  | 
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.RequestParameter;
  | 
  | @Name("detail")
  | public class Detail
  | {
  | 
  |     @RequestParameter                             [1]
  |     Long entryId;
  | 
  |     public Long getEntryId()
  |     {
  |     	return entryId;
  |     }
  | 
  |     public void setEntryId(Long entryId)
  |     {
  |     	this.entryId = entryId;
  |     }
  |     
  |     public Entry getEntry()
  |     {
  |     	return new Entry(entryId);
  |     }
  | 	
  | }
  | 

Master page (master.xhtml)

  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  | 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | 	
  | <f:view xmlns="http://www.w3.org/1999/xhtml"
  | 	  	xmlns:f="http://java.sun.com/jsf/core"
  |       	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	  	xmlns:tr="http://myfaces.apache.org/trinidad"
  | 	  	xmlns:trh="http://myfaces.apache.org/trinidad/html">
  | 	<trh:html>
  | 		<trh:body>
  | 			<tr:form>
  | 				<tr:table var="entry" value="#{master.entries}" rows="10">
  | 					<tr:column>
  | 						<f:facet name="header">
  | 							<tr:outputText value="Entry id" />
  | 						</f:facet>
  | 						<s:link action="viewDetail" value="#{entry.name}">
  | 							<f:param name="entryId" value="#{entry.id}" />
  | 						</s:link>
  | 					</tr:column>
  | 				</tr:table>
  | 			</tr:form>
  | 		</trh:body>
  | 	</trh:html>
  | </f:view>
  | 

Detail page (detail.xhtml)

  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  | 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | 	
  | <f:view xmlns="http://www.w3.org/1999/xhtml"
  | 	  	xmlns:f="http://java.sun.com/jsf/core"
  |       	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	  	xmlns:tr="http://myfaces.apache.org/trinidad"
  | 	  	xmlns:trh="http://myfaces.apache.org/trinidad/html">
  | 	<trh:html>
  | 		<trh:body>
  | 			<tr:outputText value="Entry id: #{detail.entry.id}" />
  | 			<tr:outputText value="Entry name: #{detail.entry.name}" />
  | 		</trh:body>
  | 	</trh:html>
  | </f:view>
  | 

pages.xml

  | <!DOCTYPE pages PUBLIC
  |   "-//JBoss/Seam Pages Configuration DTD 1.1//EN"
  |   "http://jboss.com/products/seam/pages-1.1.dtd">
  | 
  | <pages>
  | 	<page view-id="/master.xhtml">
  | 		<navigation>
  | 			<rule if-outcome="viewDetail">
  | 				<redirect view-id="/detail.xhtml" />
  | 			</rule>
  | 		</navigation>
  | 	</page>
  | 	<page view-id="/detail.xhtml">
  | 		<param name="entryId" value="#{detail.entryId}" />          [2]
  | 	</page>
  | </pages>
  | 

  Now the thing is that it does not work without the @RequestParameter annotation [1] (as then detail.entryId is never set), while I though that the job of initializing detail.entryId is done in pages.xml by [2]. What am I missing? Because I have to say that I am still quite confused with the concept of state propagation in Seam even though I read the documentation and played around with it for quite a while... 
  My guess is that this is due to the fact that page parameters like [2] are bidirectional while I only want to set the component property from the request parameter. So things would work fine if Master.java and Detail.java were kind of merged into one component. But that's not what I want since I want them to have different scopes - think of search screen/results. What's the proper way to propagate state in such scenario?

  Any help appreciated!
   Adam

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026922#4026922

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026922



More information about the jboss-user mailing list