1 2 Previous Next 18 Replies Latest reply on Feb 16, 2006 2:01 AM by armita Go to original post
      • 15. Re: Ending a conversation and begining another at the same t
        robjellinghaus

        OK, so of course I posted that and then thought of one last possibility, which sort of kind of worked. Declare HotelFactory.hotels as "@In ListDataModel hotels". That gets past all the bijection issues.

        Problem is it doesn't actually affect HotelListAction, because there, hotelIndex is declared as "@DataModelSelectionIndex hotelIndex". So HotelFactory can outject hotelIndex all it wants, HotelListAction isn't injecting it.

        Just changing the declaration to "@In(required=false) @DataModelSelectionIndex hotelIndex" in HotelListAction doesn't work either, because Seam tries to inject a null value for "hotelIndex", and of course you can't put a null into an int.

        Perhaps all this exposing of hotelIndex outside of HotelListAction is just wrong and I should be reorganizing HotelListAction to look at the "hotel" component (which is set by the HotelFactory after all) and drive its indexing from that on every action. I'll try that... next time I get to hack Seam... which is unfortunately only a couple of times a week right now :-( Anyway, still curious for the official word on this entire structure.

        Cheers,
        Rob

        • 16. Re: Ending a conversation and begining another at the same t
          robjellinghaus

          LAST THING: Changing HotelListAction.hotelIndex to "@In(required=false) @Out @DataModelSelectionIndex Integer hotelIndex;" doesn't work *either*, because it blows up before even calling the @Factory HotelListAction.find() method. Specifically, it blows up with:

          Feb 12, 2006 11:04:24 PM com.sun.facelets.FaceletViewHandler handleRenderException
          SEVERE: Error Rendering View
          org.jboss.seam.RequiredException: Out attribute requires value for component: hotelList.hotelIndex
           at org.jboss.seam.Component.setOutjectedValue(Component.java:867)
           at org.jboss.seam.Component.outjectFields(Component.java:845)

          Which I don't fully understand. I mean, I understand why null gets injected to HotelListAction (though I'd expect required=false to prevent that), but I don't understand why it seems to be getting outjected again before the @Factory method is even called on HotelListAction.

          This is all frustrating, since I feel like I *almost* get the concepts behind Seam, but if I'm thrashing like this then obviously there's clues I still lack. But it's kind of how it felt when I started dinking with Hibernate in early 2004, and that turned out great, so I'm still hopeful :-)
          Cheers
          Rob

          • 17. Re: Ending a conversation and begining another at the same t
            gavin.king

            Well, it is extremely unusual in a RESTful approach to have things like next and previous, since if I bookmarked the link and came back, I would have completely lost my orginal search parameters so next and last would be undefined.

            You have two options:

            (1) include the search parameters as request parameters, in which case the list is easily reconstructed by requerying in the getHotel() method (and placed in the session scope only if you need to cache it)

            (2) "just hope" that the search results are sitting in the session already, which means that your bookmark will break if the user logs out. If you want to do this broken thing, what you should do is inject HotelListAction itself into HotelAction, and expose methods like getHotels(), next() and previous() on the HotelList interface.

            Basically, since HotelAction is stateless, you are tying yourself in knots by make it be the component responsible for managing motion through the list.

            Actually, if I was really trying to do (2), what I would do in practice is merge the two components back together into a single session-scope component, since then you would have easy access to all state you are interested in. But in practice, I would do (1).

            • 18. Re: Ending a conversation and begining another at the same t
              armita

              I tryed to put my DataModel in PAGE scope as suggested n this thread using the following bean:

              @Stateful
              @Scope(ScopeType.EVENT)
              @Name("neLogic")
              @Interceptors(SeamInterceptor.class)
              
              public class NeLogicAction implements NeLogic, Serializable {
              
              
               private static Logger log =Logger.getLogger(NeLogicAction.class);
              
               @PersistenceContext(type= PersistenceContextType.EXTENDED)
               private EntityManager em;
              
               @DataModel(scope=ScopeType.PAGE)
               private List<BTS> btss;
              
               @DataModelSelectionIndex
               private int neIndex;
              
               private String searchString;
              
               public String findByName() {
               String searchPath = new String();
               searchPath = (searchString == null) ? "%" : "%" + searchString.toLowerCase() + "%";
               log.info("finding ne by name" + searchString);
               btss =em.createQuery(" from Ne n where lower(n.name) like :search")
               .setParameter("search",searchPath)
               .getResultList();
               searchString="";
               log.info("Bts found " + String.valueOf(btss.size()));
               return "nes";
               }
              
               public String getSearchString() {
               return searchString;
               }
              
               public void setSearchString(String searchString) {
               this.searchString = searchString;
               }
              }
              


              whithout success. btss is null in the render response phase.

              1 2 Previous Next