1

Is there a way to set a single property of a property in a bean?

For example, I have an Employee class as a property in my bean UserAttributeView and I want to set employeeName property from JSF using c:set tag.

<c:set value="#{item}" target="#{UserAttributeView}" property="????" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
javaAndBeyond
  • 520
  • 1
  • 9
  • 26

1 Answers1

3

The target attribute must represent the bean you'd like to set the property on.

So, given a #{bean} with an employee property which in turn has name property, this should do:

<c:set target="#{bean.employee}" property="name" value="#{item}" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you, it is working partly, means its not throwing any error, but I am getting value as null. My bean is declared as Viewscoped. Is there anything else I need to take care of. I am using it in commandbutton. – javaAndBeyond May 06 '16 at 16:27
  • In command button? It looks like you're using the wrong solution for the problem you tried to solve. Is this helpful? http://stackoverflow.com/q/4994458 Or perhaps this? http://stackoverflow.com/q/8459903 The `` can't be used as it runs during view build time (to do initialization), not during pressing the button. – BalusC May 07 '16 at 06:14