Parameters are surrounded by parentheses, and separated by commas:
<h:commandButton action="#{hotelBooking.bookHotel(hotel, user)}" value="Book Hotel"/>
The parameters hotel
and user
will be evaluated as value expressions and passed to the bookHotel()
method of the component. This gives you an alternative to the use of @In
.
Any value expression may be used as a parameter:
<h:commandButton action="#{hotelBooking.bookHotel(hotel.id, user.username)}" value="Book Hotel"/>
You may even pass literal strings using single or double quotes:
<h:commandLink action=”#{printer.println( ‘Hello world!’ )}” value=”Hello”/>
<h:commandLink action=’#{printer.println( “Hello again” )}’ value=’Hello’/>
You might even want to use this notation for all your action methods, even when you don’t have parameters to pass. This improves readability by making it clear that the expression is a method expression and not a value expression:
<s:link value="Cancel" action="#{hotelBooking.cancel()}"/>