Using JSF java classes, is it possible to programmatically create a link which passes a parameter another page.
<h:link value="Edit" outcome="edit" >
<f:param name="id" value="500" />
</h:link>
In other words what is the programmatic equivalent of the above JSF markup?
HtmlOutputLink link = new HtmlOutputLink(); // link.? = "Edit"?
// link.? = "edit"?
// link.? = 500?
Your code example is confusing. The <h:outputLink> does not have an outcome attribute at all, instead its value attribute represents the URL. Perhaps you meant to use <h:link>?
In any way, you can create <f:param> programmatically by just creating an instance of UIParameter and adding it as a child of the link component. Here's a kickoff example, assuming that you really wanted to use <h:link>.
HtmlOutcomeTargetLink link = new HtmlOutcomeTargetLink();
link.setValue("Edit");
link.setOutcome("edit");
UIParameter param = new UIParameter();
param.setName("id");
param.setValue("500");
link.getChildren().add(param);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With