- 
        1. Re: How to programmatically set a required attribute?amitev Mar 26, 2010 7:24 PM (in response to shin0135)@In(create=true) creates the component for you. 
- 
        2. Re: How to programmatically set a required attribute?shin0135 Mar 28, 2010 6:26 PM (in response to shin0135)Thanks Adrian for the answer. I'm just curious to ask, private MyDto dto = (MyDto)Component.getInstance(MyDto.class); is the above equivalent to @In(required=false) private MyDto dto; I'm trying to remove @In without losing any benefits of seam bijection provides. When I used Component.getInstance, it didn't complain about non-null required of dto. Does this mean both methods are equal to use? 
- 
        3. Re: How to programmatically set a required attribute?amitev Mar 28, 2010 10:50 PM (in response to shin0135)No, it's not equivalent. private MyDto dto = (MyDto)Component.getInstance(MyDto.class); creates a component if it doesn't exist in the scope @In(required=false) private MyDto dto; this just performs a dependency injection 
- 
        4. Re: How to programmatically set a required attribute?kragoth Mar 29, 2010 1:08 AM (in response to shin0135)
 James S. wrote on Mar 26, 2010 16:08:
 Hi,
 I have an injected property which has a required attribute false.@In(required=false) private MyDto dto; 
 I would like to convert above to like this:private MyDto dto = (MyDto)Component.getInstance(MyDto.class); 
 How can I set a required attribute programatically?
 Thank you for your help!You can't actually set the required attribute programmatically. However, you should get the same behavior by doing this: private MyDto dto = (MyDto)Component.getInstance(MyDto.class, false); What this means is: Inject an instance of MyDto.class if and only if one exits in my current context(s). Doing this is basically the same as setting required=false. The boolean represents the decision to create an instance if one does not exist.
- 
        5. Re: How to programmatically set a required attribute?shin0135 Mar 29, 2010 2:51 AM (in response to shin0135)Thanks for your clarification, Adrian and Tim. Now I understand what I was wrong. Again, thanks for your help! 
 
     
    