dev@woodstock.java.net

Re: autoValidate problem.

From: Steven Bell <bell.steven_at_gmail.com>
Date: Tue, 30 Oct 2007 13:15:29 -0700

I have found the enemy, and it is me!

So after moving to jsp pages I was getting the server side validation
executing, but my client side updates were still not working.

I was starting to build a new clean web project in order to flesh out the
problem when I noticed a few lines in the woodstock example apps
web.xmlthat I didn't have.

I had:

    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

In the woodstock example it was:

    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <init-param>
            <param-name>javax.faces.LIFECYCLE_ID</param-name>
            <param-value>com.sun.faces.lifecycle.PARTIAL</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

So after a week of digging around it looks like the problem was right in
front of my face. I'm not sure if there is still a problem with facelets
regarding the issues I was having with action vs. actionExpression and
getting the validators to work (as per my first message on this thread), but
at least I can move forward now.

By the way the "I has no properties" error went away when I added the
LIFECYCLE_ID to the servlet.

On 10/26/07, Dan Labrecque <Dan.Labrecque_at_sun.com> wrote:
>
> FYI... Although you seem to have found a workaround, I filed an issue
> with JSF Extensions.
>
> https://jsf-extensions.dev.java.net/issues/show_bug.cgi?id=83
>
> Dan
>
>
> AntonioV wrote:
>
> Hi Bill,
>
> Thanks for your reply.
>
> Yes, it seems that may be one of the root causes of the problem:
>
> I've substituted the "validatorExpression" with a <f:validator> nested in
> the <webuijsf:textField>, and now the validator is being invoked correctly.
>
> But the validation event is not being published through the dojo bus, my
> "alert" below is never invoked:
>
> // --- Subscribe to validation event. ---
>
> dojo.event.topic.subscribe(webui.suntheme.widget.textField.validation.event.endTopic,
> processEvents, "update");
>
> // --- this closure is used for validation callback ---
> var processEvents = {
> update: function(props) {
> alert("Alerta");
> var domNode = document.getElementById("plantillas:clientelabel");
> domNode.refresh();
> }
> }
>
> Any ideas on what the problem may be are indeed welcome.
>
> Thanks again,
> Antonio
>
>
>
> Bill Edwards - Sun BOS Software wrote:
>
> Not sure this helps... In my early stumbling around
> Facelets/Woodstock, I discovered
> Facelets did not like MethodExpressions very much (still expected string
> actions).
> This is basically why Actions still work. When we investigated this a
> bit, it turned
> out that JSP was providing a conversion method to wrap the
> ActionExpression return,
> but Facelets was not. Not sure where the fault lies, or rather
> anything further has
> happened to address this, but two cents worth....
>
> Steven Bell wrote:
>
> I've been doing quite a bit of digging on this, and here's what I've
> come up with so far. It may not be all right, but it's what I'm going
> with for now
>
> First, the "I has no properties" is irrelevant. It doesn't seem to
> actually indicate a problem. I still get it on pages where the
> autovalidation is working just fine.
>
> Basically there seems to be a real problem with facelets and the way
> woodstock performs actions.
>
> I'll bet that in your pages for buttons you are using action instead
> of actionExpression because actionExpression doesn't seem to work, but
> action does. That's what I was doing, and I didn't really think twice
> about it. It seems that facelets in some way is preventing the
> woodstocks normal communications.
>
> At this point in my (rather large mission critical) project I'm in the
> process of dumping facelets and going with straight jsp pages. If you
> do this you'll probably also notice that the jsp validation is much
> more strict and holds you to the taglib definitions. I had to do a
> fair amount of work to get my pages to render again, not hard, just
> time consuming.
>
> On 10/24/07, *AntonioV* <antonio_at_antonioshome.net
> <mailto:antonio_at_antonioshome.net> <antonio_at_antonioshome.net>> wrote:
>
>
> Hi,
>
> I'm also experimenting this problem (Woodstock build #14, facelets
> 1.1.13).
>
> Mozilla error console reports:
>
> Error: no element found
> Source File:
> http://localhost:8080/gesif/clientes/entrada/plantillas/alta.jsf
> Line: 1, Column: 158
> Source Code:
> <partial-response><components><render
>
> id="plantillas:clienteid"><markup><![CDATA[{"id":"plantillas:clienteid","valid":true}]]></markup></render></components>-------------------------------------------------------------------------------------------------------------------------------------------------------------^
>
>
> (There *is* a component named 'plantillas:clienteid' )
>
> And
>
> Error: I has no properties
> Source File:
> http://localhost:8080/gesif/theme/META-INF/com_sun_faces_ajax.js
> <http://localhost:8080/gesif/theme/META-INF/com_sun_faces_ajax.js> <http://localhost:8080/gesif/theme/META-INF/com_sun_faces_ajax.js>
> Line: 1
>
>
> The delayed init does *not* help, either.
>
>
>
>
> Bob Yennaco wrote:
> >
> > Does init() delayed in the onLoad:
> onLoad="setTimeout('init();', 0);"
> > Not sure if this will make a difference but it's simple enough
> to try.
> >
> > Otherwise I can tell from the jsp code snippets. Is there a DOM
> node
> > with id="components"? Does G.getElementsByTagName("components")
> return
> > an array of elements? If not, then that'd explain why I is null.
> >
> > Steven Bell wrote:
> >> Hello,
> >>
> >> I'm trying to get autoValidate to work on a textField, modeled
> after
> >> the payment page in the example app, and I keep running into a
> >> javascript error.
> >>
> >> The error is coming out of the com_sun_faces_ajax.js file in the
> >> jsf-extensions-dynamic-faces-0.1.jar. It is "I has no
> properties".
> >> The javascript that throws the error is:
> >>
> >> ...
> >> var I = G.getElementsByTagName("components")[0];
> >> var C = I.getElementsByTagName("render"); <---- I appears to
> be null
> >> here.
> >> for(var F = 0; F < C.length; F++) {
> >> ...
> >>
> >> Here is the textField code:
> >>
> >> <w:form id="PayableForm">
> >> <w:textField style="display:none;" />
> >> <w:message for="vendorGci" />
> >> <w:label id="vendorGciLabel" for="vendorGci"
> text="Vendor:
> >> " />
> >> <w:textField id="vendorGci" autoValidate="true"
> >> text="${vendorBean.searchGci}" maxlength="8"
> >> required="true"
> >> validatorExpression="#{
> vendorBean.validateVendor}" />
> >>
> >>
> >> Here is the javascript in the page (the init function is called
> from
> >> the onLoad of the body, this does happen):
> >>
> >> <w:script type="text/javascript">
> >> function VendorListener(){
> >> }
> >>
> >> function VendorNotify(props){
> >> alert("VendorNotify called!"); <--------------- I
> never see
> >> this alert message
> >> if ( props.id <http://props.id> <http://props.id> <http://props.id> <http://props.id> !=
> "PayableForm:vendorGci") {
> >> return; }
> >>
> >> var field =
> >> document.getElementById("PayableForm:vendorGciLabel");
> >> field.setProps({
> >> valid: props.valid
> >> });
> >> }
> >>
> >> VendorListener.prototype.notify = VendorNotify;
> >>
> >> function initAccountRows(){
> >> var table =
> >> document.getElementById("PayableForm:vendorAccountTable");
> >> table.initAllRows();
> >> }
> >>
> >> function init(){
> >> initAccountRows();
> >>
> >> var listener = new VendorListener();
> >> dojo.subscribe (
> >>
> webui.suntheme.widget.textField.event.validation.endTopic ,
> >> listener, listener.notify);
> >> }
> >>
> >> Here is the validator method. It currently doesn't do
> anything, just
> >> trying to get something to work. I never see the output, and I
> never
> >> hit the breakpoint in the method.
> >>
> >> public void validateVendor(FacesContext context,
> UIComponent comp,
> >> Object value){
> >> System.out.println("**********************************");
> >> System.out.println("validateVendor called");
> >> System.out.println (value);
> >> System.out.println("**********************************");
> >> }
> >>
> >>
> >> I attached a screenshot of firebug running and catching the error.
> >> The line number listed is because I used the javascript
> formatter from
> >> here:
> >>
> >> http://javascript.about.com/b/a/176259.htm
> >>
> >> To reformat the com_sun_faces_ajax.js so I could get some idea of
> >> where it was failing.
> >>
> >> Any help or ideas would be greatly appreciated.
> >>
> >> --
> >> Thanks,
> >>
> >> Steven Bell
> >>
>
> ------------------------------------------------------------------------
> >>
> >>
>
> ------------------------------------------------------------------------
>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> <mailto:dev-unsubscribe_at_woodstock.dev.java.net> <dev-unsubscribe_at_woodstock.dev.java.net>
> >> For additional commands, e-mail:
> dev-help_at_woodstock.dev.java.net
> <mailto:dev-help_at_woodstock.dev.java.net> <dev-help_at_woodstock.dev.java.net>
> >>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> <mailto:dev-unsubscribe_at_woodstock.dev.java.net> <dev-unsubscribe_at_woodstock.dev.java.net>
> > For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
> <mailto:dev-help_at_woodstock.dev.java.net> <dev-help_at_woodstock.dev.java.net>
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/autoValidate-problem.-tf4642564.html#a13395605
> <http://www.nabble.com/autoValidate-problem.-tf4642564.html#a13395605> <http://www.nabble.com/autoValidate-problem.-tf4642564.html#a13395605>
> Sent from the Project Woodstock - Dev mailing list archive at
> Nabble.com <http://Nabble.com> <http://Nabble.com>.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> <mailto:dev-unsubscribe_at_woodstock.dev.java.net> <dev-unsubscribe_at_woodstock.dev.java.net>
> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
> <mailto:dev-help_at_woodstock.dev.java.net> <dev-help_at_woodstock.dev.java.net>
>
>
>
>
> --
> Regards,
>
> Steven Bell
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>
>
>
>
>


-- 
Regards,
Steven Bell