2 Replies Latest reply on Sep 23, 2010 3:39 AM by ebu

    Can a value be somehow injected into non-seam managed field?

    ebu

      Hi!


      Could you please help me to understand if it's possible (i'm newbie to seam):


      I have a bean like:




      @Name("myAction")
      @Scope(ScopeType.CONVERSATION)
      public class MyAction {
      
        private MyDTO myDto;
      
        public void setMyDto()...
        public MyDTO getMyDto()...
      
        @Create
        @Override
        public void onCreate() {
           myDto = new MyDTO(); //it needs to be created manually
           
        }
      }





      then MyDTO:




      public class MyDTO {
         private String name;
      
         public void setName...
         public String getName...
      }





      and view:



      <h:form>
          <ui:define name="label">Name:</ui:define>
          <h:inputText id="name" value="#{myAction.myDto.name}" required="true"/>
      
          <s:link value="Next" action="#{myAction.nextStep()}" />
      </h:form>





      Despite i can see that view inputs are getting filled with initial values from the myDto i can't get them propagated back to the bean on form submit (Next link). So, the question if it's possible at all, and if so then how?



      Best regards, Eugene.




        • 1. Re: Can a value be somehow injected into non-seam managed field?
          lvdberg

          Hi,


          the s:link and s:button don't submit any value. Change to a h:button or its ajax-family member ant it will probably work.


          Leo


          P.S. Try to get rid of DTO's which is a pattern longer needed in a normal POJO - Seam application. Use dirctly the classes or make use of much simpler Home objects. If you're bridging to Spring, download the free Seam in Action chapter at Manning.com which explains very good how to do cooperate with Spring..


          • 2. Re: Can a value be somehow injected into non-seam managed field?
            ebu

            thank you, it did the trick (you probably meant h:commandButton). Regarding DTO's - i wish i could get rid of them but just can't because of legacy issues.