1 Reply Latest reply on Dec 24, 2009 11:44 AM by serkan.s.eskici.online.nl

    Calling EL with parameter is sometimes null

    serkan.s.eskici.online.nl

      Hi.


      I've a weird problem with calling EL with parameters from my xhtml page.


      The situation is as follows:



      1. I have a master page in which a complex html table gets rendered by making use of 3 nested c:foreach loops.

      2. In one of the loops I render a link which calls an action and then redirects to the detail page. I pass an object as a parameter in the action.

      3. In the detail page I load an entity with its details and with a logo (lob).

      4. The whole stuff is inside a LRC (long running conversation).



      Well, the point is that everything works fine, until I add/upload a logo to the entity. After I do that, the detail page is shown and the current conversation gets destroyed (automatically). And when I go back to the master page and click the link again, I get a NPE because the parameter in the EL also gets null (I think because the LRC gets ended).


      But this doesn't happen when I don't add a logo the Entity Bean (see below).


      So here's my code:



      @Entity   
      public class Contact implements Serializable {
          @Id
          @GeneratedValue
          @Column(nullable = false)
          private Long id;
      
          @Lob
          @Column()
          private byte[] logo;
      }
      



      @Name("itemBean")
      @Scope(CONVERSATION)
      public class ItemBean {
         
         @In
         private ItemService service;
        
         @Out
         private List<ItemVO> items;
      
         @Begin(join=true)
         @Observer("some.event.happened")
         public void init(){
              this.items = this.service.getItems();
         }
      }
      
      @Name("contactBean")
      @Scope(CONVERSATION)
      public class ContactBean {
      
         @In 
         private ContactService contactService;
        
         @Out
         private Contact selectedContact;
      
         
         public void getContact(DetailVO detail){
              this.selectedContact = this.contactService.getContact(detail.name, detail.address);
         }
      }
      




      master.xhtml:
      
      <h:form>
        <c:forEach items="#{items}" var="item>
          <h:panelGrid columns="4" rowClasses="odd,even" columnClasses=",right-aligned, ,last right-aligned">
              <f:facet name="header">
               <h:panelGroup> ... </h:panelGroup>
              </f:facet>
              <c:forEach items="#{item.types}" var="type">
               <c:forEach items="#{type.details}" var="detail" varStatus="status">
                     <h:commandLink action="#{contactBean.getContact(detail)}" value="#{detail.name}" />   ----> this redirects to detail.xhtml
                     <h:commandLink action="#{contactBean.getContact(detail)}" value="#{detail.name}">  ----> I also tried this one.
                          <s:conversationId/>
                          <s:concersationPropagation type='join' />
                     </h:commandLink>
                  </c:forEach>
              </c:forEach>
          </h:panelGrid>
        </c:forEach>
      <h:/form>
      
      
      detail.xhtml:
      ...
      <h:inputText value="#{selectedContact.name}" />
      <s:graphicImage value="#{selectedContact.logo}" alt="logo" rendered="#{not empty selectedContact.logo}">
         <s:transformImageSize height="80" maintainRatio="true" />
      </s:graphicImage>
      ... and so on
      




      I use Seam 2.1.2 with JBoss AS 4.2.3.


      Any help is welcome.


      Cheers,
      Serkan



        • 1. Re: Calling EL with parameter is sometimes null
          serkan.s.eskici.online.nl

          Sorry, I need to clarify one point:


          The detail that gets selected on the master page, must also be outjected and re-used in the detail page. That's something I did wrong in the code above.


          Thus the ContactBean should be as follows:


          @Name("contactBean")
          @Scope(CONVERSATION)
          public class ContactBean {
          
             @In 
             private ContactService contactService;
            
             @Out
             private DetailVO selectedDetail;
          
             @Out
             private Contact contact;
          
             
             public void getContact(DetailVO detail){
                  this.selectedDetail = detail;
                  this.contact = this.contactService.getContact(detail.name, detail.address);
             }
          }
          



          So the problem is that selectedDetail is null in the EL and the conversation gets ended. And all of this happens after I add a lob to the Entity Bean.