You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Robert Hodges <rh...@hotmail.com> on 2011/03/14 18:24:54 UTC

Possible bug jsf.js (or error on my pat)

To all,

I'm new to web coding (especially JSF).  I'm looking at Trinidad as my
component library of choice.  I'm trying out simple samples from the web and
this sample is not working once I include the Trinidad settings in web.xml
(it works without Trinidad being defined)

Scenario:  		Simple ajax example for a counter.  Count works, but
reset does not, reset also increments the count

Container:		tomcat 7.x
JSF Version:	2.0
Trinidad:		2.0.0 Beta 2


============================= Bean =======================================

package com.example.<deleted>;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;

@ManagedBean(name = "count")
@SessionScoped
public class Count implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	Integer count = 0;

	public Integer getCount() {
		System.out.println("Incrementing Count");
		return count++;
	}

	public void reset(ActionEvent ae) {
		System.out.println("Resetting Count");
		count = 0;
	}
}

=========================== web page ===================================

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
	xmlns:tr="http://myfaces.apache.org/trinidad">

	<h:head>
		<meta http-equiv="Content-Type"
			content="text/html; charset=iso-8859-1" />
		<title>JSF Test</title>
	</h:head>
	<h:body>
		<h:form id="form1">
			<h:outputScript> name="jsf.js" library="javax.faces"
target="head"</h:outputScript>
			<br />
			<!-- Increment the counter on the server, and the
client -->
			<h:outputText id="out1" value="#{count.count}" />
			<br />
			<h:commandButton id="button1" value="Count"
				onclick="jsf.ajax.request(this, event,
{execute: this.id, render: 'out1'}); return false;" />
			<br />
			<br />
			<!-- Resets the counter -->
			<h:commandButton id="reset" value="reset"
				onclick="jsf.ajax.request(this, event,
{execute:'reset', render: 'out1'}); return false;"
				actionListener="#{count.reset}" />
		</h:form>
	</h:body>
</html>


========================= generate page source ==========================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
&#9;&#9;<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
&#9;&#9;<title>JSF Test</title></head><body><script
type="text/javascript">var _AdfWindowOpenError='A popup window blocker has
been detected in your browser. Popup blockers interfere with the operation
of this application. Please disable your popup blocker or allow popups from
this site.';</script><script type="text/javascript"
src="/CounTest/adf/jsLibs/DebugCommon2_0_0_beta_2.js"></script><form
id="form1" name="form1" method="POST" onkeypress="return
_submitOnEnter(event,'form1');" action="/CounTest/index.xhtml"><script
type="text/javascript"> name="jsf.js" library="javax.faces"
target="head"</script>
&#9;&#9;&#9;<br>
&#9;&#9;&#9;<!-- Increment the counter on the server, and the client
--><span id="form1:out1">9</span>
&#9;&#9;&#9;<br><input id="form1:button1" name="form1:button1" type="submit"
value="Count" onclick="return _chain('jsf.ajax.request(this, event,
{execute: this.id, render: \'out1\'}); return
false;','submitForm(\'form1\',1,{source:\'form1:button1\'});return
false;',this,event,true)">
&#9;&#9;&#9;<br>
&#9;&#9;&#9;<br>
&#9;&#9;&#9;<!-- Resets the counter --><input id="form1:reset"
name="form1:reset" type="submit" value="reset" onclick="return
_chain('jsf.ajax.request(this, event, {execute:\'reset\', render:
\'out1\'}); return
false;','submitForm(\'form1\',1,{source:\'form1:reset\'});return
false;',this,event,true)"><input type="hidden"
name="org.apache.myfaces.trinidad.faces.FORM" value="form1"><input
type="hidden" name="_noJavaScript" value="false"><span
id="tr_form1_Postscript"><input type="hidden" name="javax.faces.ViewState"
value="!10n0ruibcq"><script type="text/javascript">function
_form1Validator(f,s){return _validateInline(f,s);}var
form1_SF={};</script></span><script
type="text/javascript">_submitFormCheck();</script></form></body>

</html>


My thanks,

Bob Hodges


Re: Possible bug jsf.js (or error on my pat)

Posted by Werner Punz <we...@gmail.com>.
Hi first of all which jsf version are you exactly using, myfaces or 
mojarra. And which subversion ?
I am asking because the example looks ok to me.


Werner


Am 14.03.11 18:24, schrieb Robert Hodges:
> To all,
>
> I'm new to web coding (especially JSF).  I'm looking at Trinidad as my
> component library of choice.  I'm trying out simple samples from the web and
> this sample is not working once I include the Trinidad settings in web.xml
> (it works without Trinidad being defined)
>
> Scenario:  		Simple ajax example for a counter.  Count works, but
> reset does not, reset also increments the count
>
> Container:		tomcat 7.x
> JSF Version:	2.0
> Trinidad:		2.0.0 Beta 2
>
>
> ============================= Bean =======================================
>
> package com.example.<deleted>;
>
> import java.io.Serializable;
>
> import javax.faces.bean.ManagedBean;
> import javax.faces.bean.SessionScoped;
> import javax.faces.event.ActionEvent;
>
> @ManagedBean(name = "count")
> @SessionScoped
> public class Count implements Serializable {
> 	/**
> 	 *
> 	 */
> 	private static final long serialVersionUID = 1L;
>
> 	Integer count = 0;
>
> 	public Integer getCount() {
> 		System.out.println("Incrementing Count");
> 		return count++;
> 	}
>
> 	public void reset(ActionEvent ae) {
> 		System.out.println("Resetting Count");
> 		count = 0;
> 	}
> }
>
> =========================== web page ===================================
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml"
> 	xmlns:ui="http://java.sun.com/jsf/facelets"
> 	xmlns:h="http://java.sun.com/jsf/html"
> 	xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
> 	xmlns:tr="http://myfaces.apache.org/trinidad">
>
> 	<h:head>
> 		<meta http-equiv="Content-Type"
> 			content="text/html; charset=iso-8859-1" />
> 		<title>JSF Test</title>
> 	</h:head>
> 	<h:body>
> 		<h:form id="form1">
> 			<h:outputScript>  name="jsf.js" library="javax.faces"
> target="head"</h:outputScript>
> 			<br />
> 			<!-- Increment the counter on the server, and the
> client -->
> 			<h:outputText id="out1" value="#{count.count}" />
> 			<br />
> 			<h:commandButton id="button1" value="Count"
> 				onclick="jsf.ajax.request(this, event,
> {execute: this.id, render: 'out1'}); return false;" />
> 			<br />
> 			<br />
> 			<!-- Resets the counter -->
> 			<h:commandButton id="reset" value="reset"
> 				onclick="jsf.ajax.request(this, event,
> {execute:'reset', render: 'out1'}); return false;"
> 				actionListener="#{count.reset}" />
> 		</h:form>
> 	</h:body>
> </html>
>
>
> ========================= generate page source ==========================
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
> &#9;&#9;<meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> &#9;&#9;<title>JSF Test</title></head><body><script
> type="text/javascript">var _AdfWindowOpenError='A popup window blocker has
> been detected in your browser. Popup blockers interfere with the operation
> of this application. Please disable your popup blocker or allow popups from
> this site.';</script><script type="text/javascript"
> src="/CounTest/adf/jsLibs/DebugCommon2_0_0_beta_2.js"></script><form
> id="form1" name="form1" method="POST" onkeypress="return
> _submitOnEnter(event,'form1');" action="/CounTest/index.xhtml"><script
> type="text/javascript">  name="jsf.js" library="javax.faces"
> target="head"</script>
> &#9;&#9;&#9;<br>
> &#9;&#9;&#9;<!-- Increment the counter on the server, and the client
> --><span id="form1:out1">9</span>
> &#9;&#9;&#9;<br><input id="form1:button1" name="form1:button1" type="submit"
> value="Count" onclick="return _chain('jsf.ajax.request(this, event,
> {execute: this.id, render: \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:button1\'});return
> false;',this,event,true)">
> &#9;&#9;&#9;<br>
> &#9;&#9;&#9;<br>
> &#9;&#9;&#9;<!-- Resets the counter --><input id="form1:reset"
> name="form1:reset" type="submit" value="reset" onclick="return
> _chain('jsf.ajax.request(this, event, {execute:\'reset\', render:
> \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:reset\'});return
> false;',this,event,true)"><input type="hidden"
> name="org.apache.myfaces.trinidad.faces.FORM" value="form1"><input
> type="hidden" name="_noJavaScript" value="false"><span
> id="tr_form1_Postscript"><input type="hidden" name="javax.faces.ViewState"
> value="!10n0ruibcq"><script type="text/javascript">function
> _form1Validator(f,s){return _validateInline(f,s);}var
> form1_SF={};</script></span><script
> type="text/javascript">_submitFormCheck();</script></form></body>
>
> </html>
>
>
> My thanks,
>
> Bob Hodges
>
>



Re: Possible bug jsf.js (or error on my pat)

Posted by Rudy De Busscher <rd...@gmail.com>.
Hi Bob,

Not sure why you want to use the javascript directly.  Can be done easier
with <f:ajax>

regards
Rudy

On 14 March 2011 18:24, Robert Hodges <rh...@hotmail.com> wrote:

> To all,
>
> I'm new to web coding (especially JSF).  I'm looking at Trinidad as my
> component library of choice.  I'm trying out simple samples from the web
> and
> this sample is not working once I include the Trinidad settings in web.xml
> (it works without Trinidad being defined)
>
> Scenario:               Simple ajax example for a counter.  Count works,
> but
> reset does not, reset also increments the count
>
> Container:              tomcat 7.x
> JSF Version:    2.0
> Trinidad:               2.0.0 Beta 2
>
>
> ============================= Bean =======================================
>
> package com.example.<deleted>;
>
> import java.io.Serializable;
>
> import javax.faces.bean.ManagedBean;
> import javax.faces.bean.SessionScoped;
> import javax.faces.event.ActionEvent;
>
> @ManagedBean(name = "count")
> @SessionScoped
> public class Count implements Serializable {
>        /**
>         *
>         */
>        private static final long serialVersionUID = 1L;
>
>        Integer count = 0;
>
>        public Integer getCount() {
>                System.out.println("Incrementing Count");
>                return count++;
>        }
>
>        public void reset(ActionEvent ae) {
>                System.out.println("Resetting Count");
>                count = 0;
>        }
> }
>
> =========================== web page ===================================
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml"
>        xmlns:ui="http://java.sun.com/jsf/facelets"
>        xmlns:h="http://java.sun.com/jsf/html"
>        xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
>        xmlns:tr="http://myfaces.apache.org/trinidad">
>
>        <h:head>
>                <meta http-equiv="Content-Type"
>                        content="text/html; charset=iso-8859-1" />
>                <title>JSF Test</title>
>        </h:head>
>        <h:body>
>                <h:form id="form1">
>                        <h:outputScript> name="jsf.js" library="javax.faces"
> target="head"</h:outputScript>
>                        <br />
>                        <!-- Increment the counter on the server, and the
> client -->
>                        <h:outputText id="out1" value="#{count.count}" />
>                        <br />
>                        <h:commandButton id="button1" value="Count"
>                                onclick="jsf.ajax.request(this, event,
> {execute: this.id, render: 'out1'}); return false;" />
>                        <br />
>                        <br />
>                        <!-- Resets the counter -->
>                        <h:commandButton id="reset" value="reset"
>                                onclick="jsf.ajax.request(this, event,
> {execute:'reset', render: 'out1'}); return false;"
>                                actionListener="#{count.reset}" />
>                </h:form>
>        </h:body>
> </html>
>
>
> ========================= generate page source ==========================
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
>                <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>                <title>JSF Test</title></head><body><script
> type="text/javascript">var _AdfWindowOpenError='A popup window blocker has
> been detected in your browser. Popup blockers interfere with the operation
> of this application. Please disable your popup blocker or allow popups from
> this site.';</script><script type="text/javascript"
> src="/CounTest/adf/jsLibs/DebugCommon2_0_0_beta_2.js"></script><form
> id="form1" name="form1" method="POST" onkeypress="return
> _submitOnEnter(event,'form1');" action="/CounTest/index.xhtml"><script
> type="text/javascript"> name="jsf.js" library="javax.faces"
> target="head"</script>
>                        <br>
>                        <!-- Increment the counter on the server, and the
> client
> --><span id="form1:out1">9</span>
>                        <br><input id="form1:button1" name="form1:button1"
> type="submit"
> value="Count" onclick="return _chain('jsf.ajax.request(this, event,
> {execute: this.id, render: \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:button1\'});return
> false;',this,event,true)">
>                        <br>
>                        <br>
>                        <!-- Resets the counter --><input id="form1:reset"
> name="form1:reset" type="submit" value="reset" onclick="return
> _chain('jsf.ajax.request(this, event, {execute:\'reset\', render:
> \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:reset\'});return
> false;',this,event,true)"><input type="hidden"
> name="org.apache.myfaces.trinidad.faces.FORM" value="form1"><input
> type="hidden" name="_noJavaScript" value="false"><span
> id="tr_form1_Postscript"><input type="hidden" name="javax.faces.ViewState"
> value="!10n0ruibcq"><script type="text/javascript">function
> _form1Validator(f,s){return _validateInline(f,s);}var
> form1_SF={};</script></span><script
> type="text/javascript">_submitFormCheck();</script></form></body>
>
> </html>
>
>
> My thanks,
>
> Bob Hodges
>
>

Re: Possible bug jsf.js (or error on my pat)

Posted by Cédric Durmont <cd...@gmail.com>.
Hi,

Your sample xhtml does not look very "Trinidad-ish". Maybe it was
intended for plain JSF.
a more Trinidad-oriented approach would be :
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
        xmlns:tr="http://myfaces.apache.org/trinidad">

<tr:document> <!-- yeah, I know, duplicate html tag warning, but let's
try to keep it simple -->
<tr:form>
<tr:outputText value="#{count.count}" partialTriggers="count reset"/>

<tr:commandButton text="count" id="count" partialSubmit="true"/>
<tr:commandButton text="reset" id="reset"
actionListener="#{count.reset}" partialSubmit="true"/>
</tr:form>
</tr:document>
</html>

...
Should work. For good code organization, I'd rather separate the
action (count++) from the getter. This is a trivial example, but in a
more real-world page, you never really know how ofter (and when) your
getter will be called...


Regards,
Cedric

>                <h:form id="form1">
>                        <h:outputScript> name="jsf.js" library="javax.faces"
> target="head"</h:outputScript>
>                        <br />
>                        <!-- Increment the counter on the server, and the
> client -->
>                        <h:outputText id="out1" value="#{count.count}" />
>                        <br />
>                        <h:commandButton id="button1" value="Count"
>                                onclick="jsf.ajax.request(this, event,
> {execute: this.id, render: 'out1'}); return false;" />
>                        <br />
>                        <br />
>                        <!-- Resets the counter -->
>                        <h:commandButton id="reset" value="reset"
>                                onclick="jsf.ajax.request(this, event,
> {execute:'reset', render: 'out1'}); return false;"
>                                actionListener="#{count.reset}" />
>                </h:form>
>        </h:body>
> </html>


2011/3/14 Robert Hodges <rh...@hotmail.com>:
> To all,
>
> I'm new to web coding (especially JSF).  I'm looking at Trinidad as my
> component library of choice.  I'm trying out simple samples from the web and
> this sample is not working once I include the Trinidad settings in web.xml
> (it works without Trinidad being defined)
>
> Scenario:               Simple ajax example for a counter.  Count works, but
> reset does not, reset also increments the count
>
> Container:              tomcat 7.x
> JSF Version:    2.0
> Trinidad:               2.0.0 Beta 2
>
>
> ============================= Bean =======================================
>
> package com.example.<deleted>;
>
> import java.io.Serializable;
>
> import javax.faces.bean.ManagedBean;
> import javax.faces.bean.SessionScoped;
> import javax.faces.event.ActionEvent;
>
> @ManagedBean(name = "count")
> @SessionScoped
> public class Count implements Serializable {
>        /**
>         *
>         */
>        private static final long serialVersionUID = 1L;
>
>        Integer count = 0;
>
>        public Integer getCount() {
>                System.out.println("Incrementing Count");
>                return count++;
>        }
>
>        public void reset(ActionEvent ae) {
>                System.out.println("Resetting Count");
>                count = 0;
>        }
> }
>
> =========================== web page ===================================
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml"
>        xmlns:ui="http://java.sun.com/jsf/facelets"
>        xmlns:h="http://java.sun.com/jsf/html"
>        xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
>        xmlns:tr="http://myfaces.apache.org/trinidad">
>
>        <h:head>
>                <meta http-equiv="Content-Type"
>                        content="text/html; charset=iso-8859-1" />
>                <title>JSF Test</title>
>        </h:head>
>        <h:body>
>                <h:form id="form1">
>                        <h:outputScript> name="jsf.js" library="javax.faces"
> target="head"</h:outputScript>
>                        <br />
>                        <!-- Increment the counter on the server, and the
> client -->
>                        <h:outputText id="out1" value="#{count.count}" />
>                        <br />
>                        <h:commandButton id="button1" value="Count"
>                                onclick="jsf.ajax.request(this, event,
> {execute: this.id, render: 'out1'}); return false;" />
>                        <br />
>                        <br />
>                        <!-- Resets the counter -->
>                        <h:commandButton id="reset" value="reset"
>                                onclick="jsf.ajax.request(this, event,
> {execute:'reset', render: 'out1'}); return false;"
>                                actionListener="#{count.reset}" />
>                </h:form>
>        </h:body>
> </html>
>
>
> ========================= generate page source ==========================
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
>                <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>                <title>JSF Test</title></head><body><script
> type="text/javascript">var _AdfWindowOpenError='A popup window blocker has
> been detected in your browser. Popup blockers interfere with the operation
> of this application. Please disable your popup blocker or allow popups from
> this site.';</script><script type="text/javascript"
> src="/CounTest/adf/jsLibs/DebugCommon2_0_0_beta_2.js"></script><form
> id="form1" name="form1" method="POST" onkeypress="return
> _submitOnEnter(event,'form1');" action="/CounTest/index.xhtml"><script
> type="text/javascript"> name="jsf.js" library="javax.faces"
> target="head"</script>
>                        <br>
>                        <!-- Increment the counter on the server, and the client
> --><span id="form1:out1">9</span>
>                        <br><input id="form1:button1" name="form1:button1" type="submit"
> value="Count" onclick="return _chain('jsf.ajax.request(this, event,
> {execute: this.id, render: \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:button1\'});return
> false;',this,event,true)">
>                        <br>
>                        <br>
>                        <!-- Resets the counter --><input id="form1:reset"
> name="form1:reset" type="submit" value="reset" onclick="return
> _chain('jsf.ajax.request(this, event, {execute:\'reset\', render:
> \'out1\'}); return
> false;','submitForm(\'form1\',1,{source:\'form1:reset\'});return
> false;',this,event,true)"><input type="hidden"
> name="org.apache.myfaces.trinidad.faces.FORM" value="form1"><input
> type="hidden" name="_noJavaScript" value="false"><span
> id="tr_form1_Postscript"><input type="hidden" name="javax.faces.ViewState"
> value="!10n0ruibcq"><script type="text/javascript">function
> _form1Validator(f,s){return _validateInline(f,s);}var
> form1_SF={};</script></span><script
> type="text/javascript">_submitFormCheck();</script></form></body>
>
> </html>
>
>
> My thanks,
>
> Bob Hodges
>
>