This discussion is archived
2 Replies Latest reply: Dec 5, 2012 12:01 PM by kdario RSS

Programmatically bind action to commandlink

user13279807 Newbie
Currently Being Moderated
Hi,

I am using JDev 10.1.3.5 and jsf 1.1 and am having some trouble setting up a binding for a commandlink action. I have a few different ways. I cannot do this on the jsp/x because we are building a VERY generic table in the backing.

I have tried something like the below. The row parameter seems to be the problem (the link is an a table and row is the variable used for the tablebinding).

CoreCommandLink cl = new CoreCommandLink();
MethodBinding mb;
+mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backing_mycls.getLinkAct[row]}", new Class[MyViewRowImpl]);+
+cl.setAction(mb);+

I was able to get a simple test case working without a parameter (like the below), but need some attributes from the row to call another function.

+CoreCommandLink cl = new CoreCommandLink();+
+MethodBinding mb;+
+mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backing_myclass.getLinkAct}", new Class[]);+
+cl.setAction(mb);+

I have also tried using a map and a value binding in an attempt to get a parameter passed in

+vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{backing_myclass.testCall[row]}"); // this worked+
+cl.setValueBinding(CoreCommandLink.ACTION_KEY.getName(), vb); // but this did not (java.lang.IllegalArgumentException: Property "action" cannot be bound.)+

Finally, tried a SetAction like the below but I lose the processScope before I need to retrieve the value in my action (I used the test action I got working with no parameters in conjucntion with this)

+vb = ctx.getApplication().createValueBinding("#{row}");+
+cl.setValueBinding(SetActionListener.FROM_KEY.getName(), vb);+
+vb = ctx.getApplication().createValueBinding("#{processScope.psr}");+
+cl.setValueBinding(SetActionListener.TO_KEY.getName(), vb);+

Can anyone tell me if I am on the right track with any of these approaches and what I might be missing if I am? Thank you.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points