Im new into JSF 2.0. On the last version i understand that if i want change rules about "what send to the client" i just need to configure the faces-config.xml.
Now, on version 2.0, how can manage the Action? For example, if i have this on a index.xhtml
<h:commandButton id="submit" value="submit" action="response" />
and i need to call a page called response.html (not xhtml) or that page placed into /folder/response.html, or somethings else? How can do it? I know JSF 2.0 is very flexible about these things (the concept of href links is beaten). So i think i can manage this with other methodologies, right?
The
action
can point two things:A method expression
action="#{bean.methodname}"
where the method look like this:After executing the method the action will effectively end up containing the return value of the method, like so:
action="response"
.You can also control the outcome "dynamically" the usual Java way:
Depending on the condition outcome, the action will end up like
action="somepage"
oraction="anotherpage"
Another XHTML page in the same folder as the current XHTML page. You just have to specify the filename:
action="response"
.Either way, it will go to the XHTML page which is composed by
outcome + ".xhtml"
whereoutcome
is the action value (e.g.response.xhtml
,somepage.xhtml
oranotherpage.xhtml
) which is supposed to be in the same folder as the XHTML file containing theh:commandButton
.You don't need to configure anything in
faces-config.xml
for this. Previously, during JSF 1.x ages you would need to define<navigation-case>
for this.See also: