You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Conrad <cc...@vasoftware.com> on 2005/05/28 12:03:18 UTC

Odd tapestry 4 validation problem

I'm playing around with a form with validation set up using tapestry  
4.0-alpha-3.  Things seemed to be going along smoothly when I noticed  
that after I submit a form with invalid entries, until the form was  
submitted with valid data it would stay marked up as though it was  
invalid.  It didn't matter how many times I'd go to a different page  
or refresh the form, only submitting valid data or restarting Tomcat  
would remove the invalid entry markup.  Then, to further test this, I  
checked with a browser on a different computer and, lo and behold, if  
you submit invalid data on one computer, the form would be marked up  
as though it was invalid the first time you went to that page with a  
browser on a second computer.  I'm using the default validation  
delegate and a snippet from my .page looks like:

<component id="signUpForm" type="Form">
     <binding name="listener" value="listener:signUpFormSubmit"/>
     <binding name="stateful" value="false"/>
</component>

<component id="inputUsername" type="ValidField">
     <binding name="validator" value="validator:string,required"/>
     <binding name="value" value="username"/>
</component>

And it's referenced in the template like:

<div>
     <label for="username">
         <span jwcid="@FieldLabel"  
field="component:inputUsername">Username:</span>
     </label>
     <input jwcid="inputUsername" displayName="Username:" type="text"  
size="25" id="username" />
</div>

Is this a bug or am I doing something wrong?

--Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Odd tapestry 4 validation problem

Posted by Howard Lewis Ship <hl...@gmail.com>.
There was a bug inside the bean: binding (used internally by the Form
component) that kept beans cached between requests that should not
have been ... such as the Form's default delegate.

That's just part of being alpha!

On 5/28/05, Chris Conrad <cc...@vasoftware.com> wrote:
> I'm playing around with a form with validation set up using tapestry
> 4.0-alpha-3.  Things seemed to be going along smoothly when I noticed
> that after I submit a form with invalid entries, until the form was
> submitted with valid data it would stay marked up as though it was
> invalid.  It didn't matter how many times I'd go to a different page
> or refresh the form, only submitting valid data or restarting Tomcat
> would remove the invalid entry markup.  Then, to further test this, I
> checked with a browser on a different computer and, lo and behold, if
> you submit invalid data on one computer, the form would be marked up
> as though it was invalid the first time you went to that page with a
> browser on a second computer.  I'm using the default validation
> delegate and a snippet from my .page looks like:
> 
> <component id="signUpForm" type="Form">
>      <binding name="listener" value="listener:signUpFormSubmit"/>
>      <binding name="stateful" value="false"/>
> </component>
> 
> <component id="inputUsername" type="ValidField">
>      <binding name="validator" value="validator:string,required"/>
>      <binding name="value" value="username"/>
> </component>
> 
> And it's referenced in the template like:
> 
> <div>
>      <label for="username">
>          <span jwcid="@FieldLabel"
> field="component:inputUsername">Username:</span>
>      </label>
>      <input jwcid="inputUsername" displayName="Username:" type="text"
> size="25" id="username" />
> </div>
> 
> Is this a bug or am I doing something wrong?
> 
> --Chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: BasePage, BaseComponent and thread issues with database queries

Posted by sa...@women-at-work.org.
Thanks!

So how would such a ThreadLocal example look like ?

The problem with the Visit object is that is should not be created until it
is really necessary....

> --- Ursprüngliche Nachricht ---
> Von: Pablo Ruggia <pr...@gmail.com>
> An: Tapestry users <ta...@jakarta.apache.org>
> Betreff: Re: BasePage, BaseComponent and thread issues with database
> queries
> Datum: Sat, 28 May 2005 14:45:06 -0300
> 
> On 5/28/05, sarah.simbad@women-at-work.org
> <sa...@women-at-work.org> wrote:
> > Hello everyone!
> > 
> > Both all my pages and components need to perform the same database
> queries
> > where client specific stuff (language, country) determines how they are
> > rendered.
> > 
> > (a) would it be a good idea to do everything in BasePage and let
> > BaseComponent do a getPage() and then call all methods on there ?
> 
> Personally i don't use pages to do my logic. I'd rather use my
> Business Layer. Anyway, depends on you, it's a design issue. If you
> use a logic from many components, then put that logic in the page. If
> you use the logic from one or to components, let's put that logic in
> the page.
>  
> > (b) imagine there are 10 possible groups of users and 10 possible kinds
> of
> > sql queries for all users/visitors. These are never changing, so where
> and
> > how would I cache those queries,
> 
> You can put that caché in many places. Can be a map in the Global.
> Perhaps in your database.
> 
> > (c) is it correct that instance variables within page classes are
> forbidden?
> > 
> > e.g.
> > 
> > Something something = null;
> > 
> > public Something getSomething(){
> >   if (something!=null) {
> >   return something;
> >   }
> >   else {
> >   something=getFromDatabase(clientSpecificParameters),
> >   return someting ?
> >   }
> > }
> > 
> > Would that be threadsafe? Or would users get random data belonging to
> other
> > users?
> 
> It's thread safe. But it will NOT WORK. The same user for different
> request can get different Page instances. And different users can get
> the same page instance.
> It's better to cache that thigs out of Page classes, and get those
> things from Visit, Global, ThreadLocal variables, or whatever you want
> to use.
> 
> 
> > 
> > Thanks!
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: BasePage, BaseComponent and thread issues with database queries

Posted by Pablo Ruggia <pr...@gmail.com>.
On 5/28/05, sarah.simbad@women-at-work.org
<sa...@women-at-work.org> wrote:
> Hello everyone!
> 
> Both all my pages and components need to perform the same database queries
> where client specific stuff (language, country) determines how they are
> rendered.
> 
> (a) would it be a good idea to do everything in BasePage and let
> BaseComponent do a getPage() and then call all methods on there ?

Personally i don't use pages to do my logic. I'd rather use my
Business Layer. Anyway, depends on you, it's a design issue. If you
use a logic from many components, then put that logic in the page. If
you use the logic from one or to components, let's put that logic in
the page.
 
> (b) imagine there are 10 possible groups of users and 10 possible kinds of
> sql queries for all users/visitors. These are never changing, so where and
> how would I cache those queries,

You can put that caché in many places. Can be a map in the Global.
Perhaps in your database.

> (c) is it correct that instance variables within page classes are forbidden?
> 
> e.g.
> 
> Something something = null;
> 
> public Something getSomething(){
>   if (something!=null) {
>   return something;
>   }
>   else {
>   something=getFromDatabase(clientSpecificParameters),
>   return someting ?
>   }
> }
> 
> Would that be threadsafe? Or would users get random data belonging to other
> users?

It's thread safe. But it will NOT WORK. The same user for different
request can get different Page instances. And different users can get
the same page instance.
It's better to cache that thigs out of Page classes, and get those
things from Visit, Global, ThreadLocal variables, or whatever you want
to use.


> 
> Thanks!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


BasePage, BaseComponent and thread issues with database queries

Posted by sa...@women-at-work.org.
Hello everyone!

Both all my pages and components need to perform the same database queries
where client specific stuff (language, country) determines how they are
rendered.

(a) would it be a good idea to do everything in BasePage and let
BaseComponent do a getPage() and then call all methods on there ?

(b) imagine there are 10 possible groups of users and 10 possible kinds of
sql queries for all users/visitors. These are never changing, so where and
how would I cache those queries,

(c) is it correct that instance variables within page classes are forbidden?

e.g.

Something something = null;

public Something getSomething(){
  if (something!=null) {
  return something;
  }
  else {
  something=getFromDatabase(clientSpecificParameters),
  return someting ?
  }
}

Would that be threadsafe? Or would users get random data belonging to other
users?

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org