This content has been marked as final.
Show 3 replies
-
1. Re: Out annotation and page parameter
pmuir Mar 28, 2008 5:01 PM (in response to hubaghdadi)One more time. PLEASE PROVIDE RELEVANT CODE SNIPPETS.
-
2. Re: Out annotation and page parameter
hubaghdadi Mar 31, 2008 2:39 PM (in response to hubaghdadi)@Local public interface IBook { public String loadBook(); public void setIsbn(String isbn); public String getIsbn(); public Book getLoadedBook(); }
@Stateless @Name("bookAction") public class BookAction implements IBook { @PersistenceContext private EntityManager entityManager; private String isbn; @Out(scope = ScopeType.EVENT, required = true) private Book book; @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String loadBook() { book = (Book) entityManager.createNamedQuery("findBookByIsbn").setParameter("isbn", isbn).getSingleResult(); return StringConstants.SUCCESS; } public void setIsbn(String isbn) { this.isbn = isbn; } public String getIsbn() { return this.isbn; } public Book getLoadedBook() { return book; } }
<page view-id="/book.xhtml" action="#{bookAction.loadBook}"> <param name="isbn" value="#{bookAction.isbn}" required="true"/> </page>
public class BookTest extends SeamTest { @Test public void loadBookTest() throws Exception { new NonFacesRequest("/book.xhtml") { @Override protected void beforeRequest() { setParameter("isbn", "0321146182"); } @Override protected void renderResponse() throws Exception { Book book = (Book) Contexts.getEventContext().get("book"); assert book != null; assert book.getTitle().equals("J2EE Web Services"); } }.run(); } }
-
3. Re: Out annotation and page parameter
pmuir Apr 2, 2008 12:41 PM (in response to hubaghdadi)Correct. Page parameters are set before page actions are called.