You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andrew Robinson <an...@gmail.com> on 2008/03/17 14:23:05 UTC

Re: selectOneListbox onclick - navigation

Don't call form submit manually, instead, generate a click event
manually for a command component. Check the myfaces wiki for more,
including code examples.

-Andrew

Ps On my iPod so I don't have the link handy
On 3/17/08, markus.pfeiffer@procon.co.at <ma...@procon.co.at> wrote:
> Noone tried this before?
>
>
>
> Von: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
> Gesendet: Freitag, 14. März 2008 13:13
> An: users@myfaces.apache.org
> Betreff: h:selectOneListbox onclick - navigation
>
>
>
> Hi!
>
> I tried to use the onClick Event from selectOneListBox for navigation, but
> the action method get not called:
>
>
>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
>
> <script type="text/javascript">
>
> function executeCommandLink(idLink,formName){
>
>
> document.forms[0].elements[formName+':_link_hidden_'].value=idLink;
>
> if(document.forms[formName].onsubmit){
>
> document.forms[formName].onsubmit();
>
> }
>
> document.forms[0].submit();
>
> return false;
>
> }
>
> </script>
>
> <f:subview id="subViewSelect" rendered="#{mainContrl.renderSelect}">
>
> <h:form id="fSelect" enctype="UTF-8">
>
> <h:panelGroup id="selectPG2">
>
> <h:selectOneListbox id="selectTransportListTitle"
>
> onclick="executeCommandLink('cmdLink1','fSelect')"
>
> styleClass="selectList"
> value="#{selectContrl.transportSelected}">
>
> <f:converter converterId="transportConverter" />
>
> <f:selectItems value="#{selectContrl.transportList}"
> />
>
> </h:selectOneListbox>
>
> </h:panelGroup>
>
> <h:commandLink id="cmdLink1" action="#{selectContrl.showDetail}"
> />
>
> </h:form>
>
> </f:subview>
>
>
>
>
>
> <navigation-rule>
>
> <from-view-id>/jsp/secure/main.jsp</from-view-id>
>
> <navigation-case>
>
> <from-action>#{selectContrl.showDetail}</from-action>
>
> <from-outcome>success</from-outcome>
>
> <to-view-id>/jsp/secure/detail.jsp</to-view-id>
>
> </navigation-case>
>
> </navigation-rule>
>
>
>
>
>
> private static final String SHOW_DETAIL = "success";
>
> public String showDetail() {
>
> return SelectController.SHOW_DETAIL;
>
> }
>
>