[jboss-user] [JBoss Seam] - Re: @DataModelSelection and ClassCastException

yohann49 do-not-reply at jboss.com
Fri Jul 27 06:07:51 EDT 2007


I begin to see that i've done all that stuff in a pretty wrong way. 
The factory on "lines" returns what it is used by JSF to display the lines. The DataModel were not used to outject lines, or used in a wrong way.
I changed a bit my code and get rid of the factory.
Now, the Datamodel is well outjected, and the DataModelSelection is well injected.
I've got a little problem, however. When I click on the line to select it (an <s:link> with the actionMethod selectline()), it would normally send me to another page, displaying another list.
But the page stays the same, and i have no exception sent.
I show you my new code :
pages.xml :

  |     <page view-id="/client_prod">
  |         <navigation from-action="#{LineManager.selectLine(line)}">
  |             <rule if="#{identity.loggedIn}">
  |                 <redirect view-id="/client_m.xhtml"/>
  |             </rule>
  |         </navigation>
  |     </page>
  | 
LineManager.java :

  | @Stateful
  | @Name("LineManager")
  | @Scope(SESSION)
  | public class LineManager implements LineManagerLocal, Serializable {
  | 
  |     @In
  |     private EntityManager em;
  |     
  |     @DataModel("lines")
  |     List<OrderLine> lines;
  |     
  |     
  |     
  |     @DataModelSelection("lines")
  |     private OrderLine currentOrderLine;
  |     
  |     
  |     @Out
  |     private Order myOrder;
  | 
  |    public List<OrderLine> findlines(){
  |        lines=myOrder.getOrderLines();
  |        return lines;   
  |     }
  |       @Factory(value="servs",scope=SESSION)
  |    public List<Server> searchServers(){   
  |        return currentOrderLine.getServers();    
  |     }
  |     @Begin(join=true)
  |     public void viewParameters(Order order){ 
  |         myOrder=em.merge(order);
  |         System.out.println("on rentre dans le line manager");
  |         findlines();    
  |     }
  |     public List<OrderLine> getLines(){
  |         return lines ;
  |     }
  |      @Begin(join=true)
  |      public void selectLine(Long id){
  |         //currentOrderLine=em.find(OrderLine.class,id);
  |     } 
  |      public OrderLine getCurrentOrderLine() {
  |         return currentOrderLine;
  |         
  |     }   
  |     public void setCurrentOrderLine(OrderLine currentOrderLine) {
  |         this.currentOrderLine = currentOrderLine;
  |     }  
  |     @Remove @Destroy
  |     public void destroy(){
  |     }
  |     public Order getMyOrder() {
  |         return myOrder;
  |     }
  |     public void setMyOrder(Order myOrder) {
  |         this.myOrder = myOrder;
  |     }
  |  
  | }
  | 
the code is a bit messy, since i made several tests. i'll make it up later, when i find a solution to my problem.
Thanks to those who read that 

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

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



More information about the jboss-user mailing list