Thursday, 27 November 2014

simplify your code by using f:attribute tags

There are keywords which you're keep telling to your developers like write DRY code - Don't Repeat Yourself. It is very important to write easy, clear and self-describing code. The less code you develope the easier you'll maintain and enhance it. Please check the "base" solution:

One page, one bean, two very similar actions to perform. I hope that body of the method is not copy-pasted :)

And another more declarative approach that simplifies the solution - f:attribute tag inside af:commandButton. In your page source you need to add the attributes as shown below and in the action handle method consume it/them. The effect is the same.

 Which is more important, you can use an EL expression there.