1 Reply Latest reply on Jan 22, 2014 8:02 AM by Martin Kouba

    CDI @Produces doesn't return value from jsf

    Alexander Mayr Newbie

      Hello,

      I tried to add @Produces to my variables in my backingbean like this:

      
      
      
      
      @Produces
      
      
      
      @Named
      
      
      
      String selectedCustomerFirstname;
      
      
      
      

       

      and removed the getters and setters. In my xhtml page I show the value like this:

      <p:inputText value="#{selectedCustomerFirstname}" ></p:inputText>
      

       

      The problem now is that the value gets displayed correctly, but if I change it and submit the form, the backingbean always receives the old value... Does ayone have a solution to this problem?

        • 1. Re: CDI @Produces doesn't return value from jsf
          Martin Kouba Master

          Hi Alexander,

          I think this could never work. #{selectedCustomerFirstname} resolves to an immutable String instance (your producer is dependent and thus the field value is retrieved for every evaluation of the EL expression). So there is no way to propagate your change to the original backing bean when the you submit the form - I mean JSF value binding will not work here. Do you have a reason to use producer field?