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 <rhodges_bob@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
>
>
|