Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically create a JSF HtmlOutputLink

Tags:

java

jsf-2

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?
like image 409
auser Avatar asked Nov 30 '25 04:11

auser


1 Answers

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);
like image 59
BalusC Avatar answered Dec 01 '25 18:12

BalusC