Sunday, April 08, 2007

ADF Faces: Programmatically setting SetActionListener….WHY?

Question: Because the af:setActionListener component is intended to avoid some managed bean code, is there any particular reason why programming with SetActionListener should be preferred?

1) MORE CONTROL: it gives more control...e.g. we can have:

if(A) EL.set("#{sessionScope.someOtherAttribute}", EL.get("#{sessionScope.someAttribute}"));

else if (B) EL.set("#{sessionScope.someOtherAttribute}", EL.get("#{sessionScope.someAttribute2}"));

2) NO CASTING ISSUES: There are casting issues with af:SetActionListener when TO field is pointing to primitive data type e.g. boolean (small b)

if a variable (e,g, enbaleUpdate) is of type boolean rather Boolean then the following line throws EvaluationException ( IllegalArgumentException: type mismatch)

<af:setActionListener to="#{UserStateBean.enableUpdate}" from="true"/>

3) EASIER TO DEBUG: For case like (2) I have found it pretty hard to debug af:SetActionListener component (as compared to code in backing bean)

1 comment:

Anonymous said...

Hi Asim,
Glad to see another JDeveloper user starting a blog.
One thing that can be helpful is if you add an RSS feed to your blog options - this will allow us to add it to blog aggregators such as http://jdeveloperblog.com/ and http://orablogs.com