You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ma...@procon.co.at on 2008/03/14 13:12:58 UTC
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;
}
AW: selectOneListbox onclick - navigation
Posted by ma...@procon.co.at.
I did nothing changed no action method get called..
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 09:05
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
can you remove false and try it
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:33 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
No the script got called (tried with alert() ) and no error occurred.
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:56
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
are you getting any javascript error?
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:25 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
Its not my idea i must do it with onClick is it possible? Someone know
how?
This JS is not from me I found it there:
http://forum.java.sun.com/thread.jspa?threadID=728865
<http://forum.java.sun.com/thread.jspa?threadID=728865&messageID=4199662>
&messageID=4199662
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:45
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
why do you want to use onclick for submiting? you can use any of the
listeners in jsf.
btw, returning false in script method will not submit the form.
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
RE: selectOneListbox onclick - navigation
Posted by kr...@wipro.com.
can you remove false and try it
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:33 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
No the script got called (tried with alert() ) and no error occurred.
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:56
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
are you getting any javascript error?
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:25 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
It's not my idea - i must do it with onClick - is it possible? Someone know how?
This JS is not from me - I found it there: http://forum.java.sun.com/thread.jspa?threadID=728865&messageID=4199662
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:45
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
why do you want to use onclick for submiting? you can use any of the listeners in jsf.
btw, returning false in script method will not submit the form.
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
AW: selectOneListbox onclick - navigation
Posted by ma...@procon.co.at.
No the script got called (tried with alert() ) and no error occurred.
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:56
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
are you getting any javascript error?
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:25 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
Its not my idea i must do it with onClick is it possible? Someone know
how?
This JS is not from me I found it there:
http://forum.java.sun.com/thread.jspa?threadID=728865
<http://forum.java.sun.com/thread.jspa?threadID=728865&messageID=4199662>
&messageID=4199662
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:45
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
why do you want to use onclick for submiting? you can use any of the
listeners in jsf.
btw, returning false in script method will not submit the form.
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
RE: selectOneListbox onclick - navigation
Posted by kr...@wipro.com.
are you getting any javascript error?
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:25 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
It's not my idea - i must do it with onClick - is it possible? Someone know how?
This JS is not from me - I found it there: http://forum.java.sun.com/thread.jspa?threadID=728865&messageID=4199662
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:45
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
why do you want to use onclick for submiting? you can use any of the listeners in jsf.
btw, returning false in script method will not submit the form.
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
AW: selectOneListbox onclick - navigation
Posted by ma...@procon.co.at.
Its not my idea i must do it with onClick is it possible? Someone know
how?
This JS is not from me I found it there:
http://forum.java.sun.com/thread.jspa?threadID=728865
<http://forum.java.sun.com/thread.jspa?threadID=728865&messageID=4199662>
&messageID=4199662
Von: krishna.srinivasank@wipro.com [mailto:krishna.srinivasank@wipro.com]
Gesendet: Montag, 17. März 2008 08:45
An: users@myfaces.apache.org
Betreff: RE: selectOneListbox onclick - navigation
why do you want to use onclick for submiting? you can use any of the
listeners in jsf.
btw, returning false in script method will not submit the form.
_____
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com
RE: selectOneListbox onclick - navigation
Posted by kr...@wipro.com.
why do you want to use onclick for submiting? you can use any of the listeners in jsf.
btw, returning false in script method will not submit the form.
________________________________
From: markus.pfeiffer@procon.co.at [mailto:markus.pfeiffer@procon.co.at]
Sent: Monday, March 17, 2008 1:11 PM
To: 'MyFaces Discussion'
Subject: AW: selectOneListbox onclick - navigation
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;
}
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
AW: selectOneListbox onclick - navigation
Posted by ma...@procon.co.at.
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;
}
Re: h:selectOneListbox onclick - navigation
Posted by Michael Kurz <mi...@gmx.at>.
markus.pfeiffer@procon.co.at schrieb:
> Hi!
>
> I tried to use the onClick Event from selectOneListBox for navigation,
> but the action method get not called:
>
> <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>
I guess your problem is related to identifiers. In javascript you have
to use the clientIds of the components. The clientId is NOT the same as
the id you gave the component. It is composed of the ids of all naming
containers which are parents of the component and the component id
itself with : in between. For you this should be (as subview and form
are naming containers adding their id to the clientId):
subViewSelect:fSelect
subViewSelect:fSelect:cmdLink1
One hint: look at the rendered html code of your page. MyFaces renders
javascript to submit a form with a commandLink - that should be what you
need (or close to it ;-) ). And here's another one: try to get familiar
with the id concept of jsf (clientId, naming container...). This will
help you a lot.
The following code should work (it is only a quick hack!!):
function submitIt(idLink, formName) {
var form = document.forms[formName];
form.elements[formName+':_idcl'].value=idLink;
form.submit();
}
when you call:
submitIt('subViewSelect:fSelect:cmdLink1', 'subViewSelect:fSelect');
have a nice evening, regards
Michael Kurz