- 
        2. Re: Newbei question: Page navigationzwu_ca May 24, 2007 1:15 AM (in response to zwu_ca)Thanks a lot: Almost worked -- how ever it lost the request string "?a=15" in the original url. Any more tip? 
- 
        3. Re: Newbei question: Page navigationgavin.king May 24, 2007 9:42 AM (in response to zwu_ca)Declare the parameter as a seam page parameter. 
- 
        4. Did this -- but not working (Re: Newbei question: Page navigzwu_ca May 24, 2007 10:15 AM (in response to zwu_ca)
 Thanks for help -- this has been driving me crazy (more than 12 hours have been spent -- a newbie in Seam).
 I think I did do this: Could you look at what's wrong with the navigation (I also include the related Java code). Your help will be much appreciated.
 <page view-id="/home.xhtml">
 <redirect view-id="/itemlist.xhtml"/>
 <page view-id="/itemlist.xhtml" login-required="true" >
 <navigation from-action="#{hotelBooking.cancel}">
 <redirect view-id="/main.xhtml"/>
 import javax.ejb.*;
 /**
 *
 * @author WuZX
 */
 @Local
 public interface Itemlist
 {
 UploadedData getData();
 String getMe();
 void setMe(String me);
 /*
 public void setDamn(String id);
 public String getDamn();
 */
 public void destroy();
 }
 /**
 *
 * @author WuZX
 */
 import static org.jboss.seam.ScopeType.STATELESS;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Out;
 import org.jboss.seam.annotations.Factory;
 import org.jboss.seam.annotations.RequestParameter;
 import org.jboss.seam.annotations.Create;
 import org.jboss.seam.annotations.Destroy;
 import javax.ejb.Remove;
 import javax.ejb.*;
 import org.jboss.logging.Logger;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 @Stateful
 @Name("itemlist")
 //@Scope(STATELESS)
 public class ItemlistAction implements Itemlist {
 //@In String id;
 // private UploadedData uploadedData;
 @PersistenceContext
 private EntityManager em;
 @RequestParameter("id")
 private String id;
 private static final Logger log = Logger.getLogger(ItemlistAction.class);
 static
 {
 log.info("loading?****************");
 }
 /*public String getData()
 {
 return "data" + id;
 }*/
 //@Out
 //@Factory("uploadedData")
 public UploadedData getData()
 {
 log.info("get here" + id);
 if (id == null )
 {
 //UploadedData uploadedData = new UploadedData();
 //uploadedData.setTesting("testing");
 return null;
 }
 return em.find(UploadedData.class, new Long(id));
 }
 public String getMe()
 {
 return id;
 }
 public void setMe(String me)
 {
 id = me;
 }
 public int getDataID()
 {
 return 3;
 /* try
 {
 if (id != null)
 return Integer.parseInt(id);
 }
 catch(Exception e)
 {
 }
 return 0;
 */
 }
 @Destroy @Remove
 public void destroy() {}
 }
- 
        5. Page navigation part resent (Re: Newbei question: Page navizwu_ca May 24, 2007 10:21 AM (in response to zwu_ca)Sorry I didn't put the tag, which caused the text uncomprensive. Here I tried. The java code is in previous posting. <page view-id="/home.xhtml"> <navigation> <rule if="#{identity.loggedIn}"> <redirect view-id="/itemlist.xhtml"/> </rule> </navigation> </page> <page view-id="/itemlist.xhtml" login-required="true" > <param name="id" value="#{itemlist.me}" /> <navigation from-action="#{hotelBooking.cancel}"> <redirect view-id="/main.xhtml"/> </navigation> </page>
- 
        6. Re: Newbei question: Page navigationgavin.king May 24, 2007 10:29 AM (in response to zwu_ca)I don't see any page parameter declaration in pages.xml. 
 http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/events.html#d0e3803
- 
        7. Re: Newbei question: Page navigationgavin.king May 24, 2007 10:30 AM (in response to zwu_ca)There needs to be <param name="a" value="...."/> 
- 
        8. Didn't get it: Re: Newbei question: Page navigationzwu_ca May 24, 2007 11:08 AM (in response to zwu_ca)Thanks again for the help: I didn't get what you meant with <param name="a" value="...."/> 
 The param I had is 'id' and I had the line:<param name="id" value="#{itemlist.me}" />
 Did I put the line in a wrong place?
- 
        9. Re: Newbei question: Page navigationgavin.king May 24, 2007 11:15 AM (in response to zwu_ca)In your original post, you typed "a". Which is it? 
- 
        10. Re: Newbei question: Page navigationzwu_ca May 24, 2007 11:29 AM (in response to zwu_ca)First I am so thankful you are so patient and so willing to help -- very rarely. 
 I don't see 'a' anywhere in the original code posting. I forgot to use the 'code' html tag in the original code. There might be some confusion there (you might have different views from mine?). I will try to post the code again here (hopefully this time it can be resolved ).<page view-id="/home.xhtml"> <navigation> <rule if="#{identity.loggedIn}"> <redirect view-id="/itemlist.xhtml"/> </rule> </navigation> </page> <page view-id="/itemlist.xhtml" login-required="true" > <param name="id" value="#{itemlist.me}" /> <navigation from-action="#{hotelBooking.cancel}"> <redirect view-id="/main.xhtml"/> </navigation> </page> import javax.ejb.*; /** * * @author WuZX */ @Local public interface Itemlist { UploadedData getData(); String getMe(); void setMe(String me); /* public void setDamn(String id); public String getDamn(); */ public void destroy(); } /** * * @author WuZX */ import static org.jboss.seam.ScopeType.STATELESS; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.Factory; import org.jboss.seam.annotations.RequestParameter; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.Scope; import javax.ejb.Remove; import javax.ejb.*; import static org.jboss.seam.ScopeType.*; import org.jboss.logging.Logger; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @Stateful @Name("itemlist") @Scope(EVENT) public class ItemlistAction implements Itemlist { //@In String id; // private UploadedData uploadedData; @PersistenceContext private EntityManager em; @RequestParameter("id") private String me; private static final Logger log = Logger.getLogger(ItemlistAction.class); static { log.info("loading?****************"); } /*public String getData() { return "data" + id; }*/ //@Out //@Factory("uploadedData") public UploadedData getData() { log.info("get here" + me); if (me == null ) { //UploadedData uploadedData = new UploadedData(); //uploadedData.setTesting("testing"); return null; } return em.find(UploadedData.class, new Long(me)); } public String getMe() { log.info("===============get me " + me); return me; } public void setMe(String me) { log.info("================= set me here" + me); this.me = me; } public int getDataID() { return 3; /* try { if (id != null) return Integer.parseInt(id); } catch(Exception e) { } return 0; */ } @Destroy @Remove public void destroy() {} }
- 
        11. Re: Newbei question: Page navigationgavin.king May 24, 2007 11:38 AM (in response to zwu_ca)You typed: If user opens a page: http://my/link.seam?a=3 and if user has not logged on, it will redirect the link to http://my/home.seam. After user enters correct credentials and hits "Login" button, the page should go back to http://my/link.seam?a=3. How this logic can be implemented is Seam? Almost worked -- how ever it lost the request string "?a=15" in the original url. 
 Well, I don't see the following in your pages.xml:<event type="org.jboss.seam.notLoggedIn"> <action expression="#{redirect.captureCurrentView}"/> </event> <event type="org.jboss.seam.postAuthenticate"> <action expression="#{redirect.returnToCapturedView}"/> </event>
- 
        12. I did have the lines: Re: Newbei question: Page navigationzwu_ca May 24, 2007 1:21 PM (in response to zwu_ca)As I said, it did go back to the pag but with Query String cut off. I wanted the origignal link "http://my/itemlist.seam?id=20" instead of "http://my/itemlist.seam?cid=3". PLEASE NOTE the 'cid' is the generic Query Parameter, not my 'id'. 
 If I hadn't the two lines, it would have gone back at all.
 This is the complete file:<!DOCTYPE pages PUBLIC "-//JBoss/Seam Pages Configuration DTD 1.2//EN" "http://jboss.com/products/seam/pages-1.2.dtd"> <pages no-conversation-view-id="/main.xhtml" login-view-id="/home.xhtml"> <page view-id="/uploadResponse.xhtml"> <param name="pid" value="#{personDao.id}" converterId="javax.faces.Long"/> </page> <page view-id="/register.xhtml"> <action if="#{validation.failed}" execute="#{register.invalid}"/> <navigation> <rule if="#{register.registered}"> <redirect view-id="/home.xhtml"/> </rule> </navigation> </page> <page view-id="/home.xhtml"> <navigation> <rule if="#{identity.loggedIn}"> <redirect view-id="/itemlist.xhtml"/> </rule> </navigation> </page> <page view-id="/itemlist.xhtml" login-required="true" > <param name="id" value="#{itemlist.me}" /> <navigation from-action="#{hotelBooking.cancel}"> <redirect view-id="/main.xhtml"/> </navigation> </page> <page view-id="/password.xhtml" login-required="true"> <navigation> <rule if="#{changePassword.changed}"> <redirect view-id="/main.xhtml"/> </rule> </navigation> </page> <page view-id="/main.xhtml" login-required="true"> <navigation from-action="#{hotelBooking.selectHotel(hot)}"> <redirect view-id="/hotel.xhtml"/> </navigation> <navigation from-action="#{bookingList.cancel}"> <redirect/> </navigation> </page> <page view-id="/hotel.xhtml"> <description>View hotel: #{hotel.name}</description> <navigation from-action="#{hotelBooking.bookHotel}"> <redirect view-id="/book.xhtml"/> </navigation> </page> <page view-id="/book.xhtml"> <description>Book hotel: #{hotel.name}</description> <navigation from-action="#{hotelBooking.setBookingDetails}"> <rule if="#{hotelBooking.bookingValid}"> <redirect view-id="/confirm.xhtml"/> </rule> </navigation> </page> <page view-id="/confirm.xhtml"> <description>Confirm booking: #{booking.description}</description> <navigation from-action="#{hotelBooking.confirm}"> <redirect view-id="/main.xhtml"/> </navigation> </page> <page view-id="*"> <navigation from-action="#{identity.logout}"> <redirect view-id="/home.xhtml"/> </navigation> <navigation from-action="#{hotelBooking.cancel}"> <redirect view-id="/main.xhtml"/> </navigation> </page> <event type="org.jboss.seam.notLoggedIn"> <action expression="#{redirect.captureCurrentView}"/> </event> <event type="org.jboss.seam.postAuthenticate"> <action expression="#{redirect.returnToCapturedView}"/> </event> <exception class="org.jboss.seam.security.NotLoggedInException"> <redirect view-id="/home.xhtml"> <message severity="warn">You must be logged in to use this feature</message> </redirect> </exception> </pages>
- 
        13. About the 'a' --Re: Newbei question: Page navigationzwu_ca May 24, 2007 3:11 PM (in response to zwu_ca)
 Oh, you meant the 'a' in the very first posting. That's what I wanted to get an idea how this could be done. Then I tried my actual things and then they didn't work as I wanted, then I went to implementation details : When you talked about 'a' and I forgot the 'a' in the very first posting. But this still has not been resolved. I reluctantly (because you had lots of time with me already) asked you to help again.
- 
        14. Finally Got it: Page navigationzwu_ca May 24, 2007 11:29 PM (in response to zwu_ca)Got it now -- I don't think it was not so nice : several internal redirections may have happens (since I can see the get and set methods called several times). In order not to lost the value of my bean variable, I have to let it not be set if the Query variable is null. 
 I think this part of the implementation of SEAM is problemlic, or at least not very nice.
 
     
    