Odd tapestry 4 validation problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Odd tapestry 4 validation problem

cconrad
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

BasePage, BaseComponent and thread issues with database queries

sarah.simbad
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Odd tapestry 4 validation problem

Howard Lewis Ship
In reply to this post by cconrad
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: BasePage, BaseComponent and thread issues with database queries

Pablo Ruggia
In reply to this post by sarah.simbad
On 5/28/05, [hidden email]
<[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: BasePage, BaseComponent and thread issues with database queries

sarah.simbad
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 <[hidden email]>
> An: Tapestry users <[hidden email]>
> Betreff: Re: BasePage, BaseComponent and thread issues with database
> queries
> Datum: Sat, 28 May 2005 14:45:06 -0300
>
> On 5/28/05, [hidden email]
> <[hidden email]> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]