Page navigation with SelectOneRadio

[nobr]Is it possible to do page navigation with just selectOneRadio choice and without link or command button?

<h:form id="form1" styleClass="form">

<h:selectOneRadio disabledClass="selectOneRadio_Disabled"

enabledClass="selectOneRadio_Enabled" id="radio1"

styleClass="selectOneRadio" layout="pageDirection"

value="#{Main.selectedValue}"

valueChangeListener="#{Main.handleRadio1ValueChange}"

immediate="true" onclick="submit()">

<f:selectItem itemValue="page1" itemLabel="page1" />

<f:selectItem itemValue="page2" itemLabel="page2" />

<f:selectItem itemValue="page3" itemLabel="page3" />

</h:selectOneRadio>

<br>

</h:form>

public String handleRadio1ValueChange(ValueChangeEvent valueChangedEvent){

String s = (String)valueChangedEvent.getNewValue().toString();

return s;

}

And faces-config:

<navigation-rule>

<from-view-id>/main.jsp</from-view-id>

<navigation-case>

<from-action>#{Main.handleRadio1ValueChange}</from-action>

<from-outcome>page1</from-outcome>

<to-view-id>/page1.jsp</to-view-id>

</navigation-case>

</navigation-rule>

[/nobr]

[1935 byte] By [basti78a] at [2007-11-26 22:16:32]
# 1

I hope u figured out a solution for this post already. But, if not u can try this. It worked for me.

In the change listener method, add these few lines for redirecting the control to required page.

FacesContext facesContext = FacesContext.getCurrentInstance();

ExternalContext externalContext = facesContext.getExternalContext();

facesContext.responseComplete();

HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();

try {

response.sendRedirect("abc.jspx");

} catch (Exception e) {

e.printStackTrace();

}

Regards, Hari.

Hari.Redroutua at 2007-7-10 11:09:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Short answer: no.

More useful answer: there are a few ways around this. The previous poster suggested one.

Another is to click a hidden commandButton using the selectOneRadio's onlick(). e.g.

<h:selectOneRadio ... onclick="document.getElementById('myform:button').click();" />

<h:commandButton action="#{Main.action}" style="display: none;" id="button" />

Then let JSF do the standard navigation stuff with the commandButton.

guy.colemana at 2007-7-10 11:09:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...