Reputation: 7728
I feel a little dumb: I am using Primefaces on Tomcat 7 and would like to use those fancy new EL expressions to reduce some code clutter. I figured out how to do this in datatables but I can't get it to work otuside recurring structures which have those handy var
attributes. How would I declare the EL parameter for grantRole(String)
to be the value of the inputText
?
<h:panelGrid columns="3">
<h:outputText value="Name" />
<p:inputText/>
<p:commandButton value="Add" update="associatedPlayers"
action="#{permissionRoleDetailBean.grantRole(associatePlayerName)}" />
</h:panelGrid>
Upvotes: 1
Views: 421
Reputation: 1109635
You could do so:
<h:panelGrid columns="3">
<h:outputText value="Name" />
<p:inputText binding="#{playerName}" />
<p:commandButton value="Add" update="associatedPlayers"
action="#{permissionRoleDetailBean.grantRole(playerName.value)}" />
</h:panelGrid>
However, this makes no sense. The normal approach is the following:
<h:panelGrid columns="3">
<h:outputText value="Name" />
<p:inputText value="#{permissionRoleDetailBean.playerName}" />
<p:commandButton value="Add" update="associatedPlayers"
action="#{permissionRoleDetailBean.grantRole}" />
</h:panelGrid>
with
private String playerName; // +getter+setter
public void grantRole() {
System.out.println(playerName); // Look, it's already set by JSF.
}
Upvotes: 4