Re: Conditional Validation in t5

2010-03-04 Thread 56G3W

am trying the same example , But could you show us the autheticator java
class :)
Mine is :
package org.example.myapp.services;

public class UserAuthenticator {
public String userName;
public String password;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isValide(String usr,String pass)
{
if(usr.equals(usr)pass.equals(pass))
{
System.out.println(usr);
System.out.println(pass);
return true;
}
else return false;


}


}
but it did not work i got this message:
15:48:53,505 INFO  [STDOUT] [ERROR] TapestryModule.RequestExceptionHandler
Processing of request failed with uncaught exception:
java.lang.ClassNotFoundException: caught an exception while obtaining a
class file for org.example.myapp.pages.Contact
java.lang.RuntimeException: java.lang.ClassNotFoundException: caught an
exception while obtaining a class file for org.example.myapp.pages.Contact
at
org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.findClass(ComponentInstantiatorSourceImpl.java:300)
at
org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.getInstantiator(ComponentInstantiatorSourceImpl.java:276)
at
$ComponentInstantiatorSource_12728c0ea0e.getInstantiator($ComponentInstantiatorSource_12728c0ea0e.java)
at
org.apache.tapestry5.internal.pageload.PageLoaderImpl.createAssembler(PageLoaderImpl.java:193)
at
org.apache.tapestry5.internal.pageload.PageLoaderImpl.getAssembler(PageLoaderImpl.java:183)
at
org.apache.tapestry5.internal.pageload.PageLoaderImpl.loadPage(PageLoaderImpl.java:157)
at $PageLoader_12728c0ea3e.loadPage($PageLoader_12728c0ea3e.java)
at
org.apache.tapestry5.internal.services.PagePoolCache.checkout(PagePoolCache.java:210)
at
org.apache.tapestry5.internal.services.PagePoolImpl.checkout(PagePoolImpl.java:99)
at $PagePool_12728c0ea3d.checkout($PagePool_12728c0ea3d.java)
at
org.apache.tapestry5.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:51)
at $RequestPageCache_12728c0ea3c.get($RequestPageCache_12728c0ea3c.java)
at $RequestPageCache_12728c0ea35.get($RequestPageCache_12728c0ea35.java)
at
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:52)
at
org.apache.tapestry5.services.TapestryModule$33.handle(TapestryModule.java:1943)
at
$PageRenderRequestHandler_12728c0ea38.handle($PageRenderRequestHandler_12728c0ea38.java)
at
$PageRenderRequestHandler_12728c0ea23.handle($PageRenderRequestHandler_12728c0ea23.java)
at
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
at
$ComponentRequestHandler_12728c0ea28.handlePageRender($ComponentRequestHandler_12728c0ea28.java)
at
org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:45)
at $Dispatcher_12728c0ea2a.dispatch($Dispatcher_12728c0ea2a.java)
at $Dispatcher_12728c0ea21.dispatch($Dispatcher_12728c0ea21.java)
at
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245)
at
org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_12728c0ea22.service($RequestHandler_12728c0ea22.java)
at
org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:778)
at $RequestHandler_12728c0ea22.service($RequestHandler_12728c0ea22.java)
at
org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:767)
at $RequestHandler_12728c0ea22.service($RequestHandler_12728c0ea22.java)
at
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
at $RequestHandler_12728c0ea22.service($RequestHandler_12728c0ea22.java)
at org.example.myapp.services.AppModule$1.service(AppModule.java:96)
at $RequestFilter_12728c0ea1d.service($RequestFilter_12728c0ea1d.java)
at $RequestHandler_12728c0ea22.service($RequestHandler_12728c0ea22.java)
at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90)
at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:81)
at

Re: Conditional Validation in t5

2008-10-24 Thread Daniel Alonso Sanchez

For god's shake, thanks a lot for your response,Hugo! I was trying something
different for activate validations in both sides, but, due to the
restrictions I think I'm gonna follow your idea.

Thanks a lot again for your time :D
-- 
View this message in context: 
http://www.nabble.com/Conditional-Validation-in-t5-tp20126760p20147177.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Conditional Validation in t5

2008-10-23 Thread Hugo Palma
It sure is possible.
Looking at your use case my approach would be to implement those conditional
validation on the onValidateForm method in your page / component class.

For example:

public class Login
{
  @Persist
  @Property
  private String userId;

  @Property
  private String password;

  @Component
  private Form form;

  @Inject
  private LoginAuthenticator authenticator;

  void onValidateForm()
  {
if (! authenticator.isValidLogin(userId, password))
{
  form.recordError(Invalid user name or password.);
}
  }

  Object onSuccess()
  {
return PostLogin.class;
  }

}




On Thu, Oct 23, 2008 at 9:37 AM, Daniel Alonso Sanchez [EMAIL PROTECTED]wrote:


 Hi everybody, we are in a hurry in our project, because some requirements
 made us to put somethin like Conditional Validations.

 For instance, input components (textfield, select, ...) will always have
 format validations, but when the page will be invoked with a parameter, a
 validation required  is desired to be added to the set of validations per
 field.

 Could this be possible? Is there anyway to do it without duplication the
 pages?

 Please, if anyone knows how to do it or is just impossible, pleas, tell me
 something as soon as possible. Thanks a lot in advance.
 --
 View this message in context:
 http://www.nabble.com/Conditional-Validation-in-t5-tp20126760p20126760.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




RE: Conditional validation in T4?

2007-12-21 Thread Marcus.Schulte
You can bind your validators dynamically
(validatory=ognl:conditionalValidStuff )
and submit changes of you pre-conditions via @EventListener.
Sounds a bit like overkill for simple dependencies, but can do very
complex things 

 -Original Message-
 From: Drew McAuliffe [mailto:[EMAIL PROTECTED] 
 Sent: Friday, December 21, 2007 8:25 AM
 To: [EMAIL PROTECTED]
 Subject: Conditional validation in T4?
 
 I'm running into a problem with validators in T4. I have a 
 situation where I sometimes need to validate a field on a 
 form, but only if another field on the same form has a 
 certain set of values. For example, a ship quantity
 field on an order form is only required if the order delivery 
 method is shipment and not download (you don't have a 
 ship quantity for an order that doesn't ship). Again, both 
 fields are on the same form.
 Maybe I'm missing something but I don't know how to make the 
 use of a validator conditional. I don't want to do manual 
 validation in the submit method. I've tried setting the 
 validators of the text field to a method on the page class 
 that checks the field values, but it seems that the 
 validation does not have access to the runtime selection made 
 by the user.
 In other words, at the time my method tries to check if a 
 validator is necessary, it is looking at old data and doesn't 
 have access to the value the user was trying to submit. 
 Something related to when in the page cycle validation is 
 checked, I'm sure.
 
 Any ideas? This is for server-side validation, though of 
 course client-side validation would be really nice too! (I 
 imagine that would have to be using some sort of async 
 callback method).
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Conditional validation in T4?

2007-12-21 Thread Steve Shucker

http://tapestry.apache.org/tapestry4.1/usersguide/validation.html
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/validator/Identity.html

Look at the match/differ validators.  The cover the basic concept of a 
validator that acts on two components.  You can probably write a variant 
of the Identity class that will throw a ValidatorException is the 
referent is non-null and the validated control is null.


Another approach would be to encapsulate the interrelated controls in a 
component to be validated as a group.  I think there's an example of 
this in Kent Tong's book.


-Steve

Drew McAuliffe wrote:

I'm running into a problem with validators in T4. I have a situation where I
sometimes need to validate a field on a form, but only if another field on
the same form has a certain set of values. For example, a ship quantity
field on an order form is only required if the order delivery method is
shipment and not download (you don't have a ship quantity for an order
that doesn't ship). Again, both fields are on the same form.
Maybe I'm missing something but I don't know how to make the use of a
validator conditional. I don't want to do manual validation in the submit
method. I've tried setting the validators of the text field to a method on
the page class that checks the field values, but it seems that the
validation does not have access to the runtime selection made by the user.
In other words, at the time my method tries to check if a validator is
necessary, it is looking at old data and doesn't have access to the value
the user was trying to submit. Something related to when in the page cycle
validation is checked, I'm sure.

Any ideas? This is for server-side validation, though of course client-side
validation would be really nice too! (I imagine that would have to be using
some sort of async callback method).

  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Conditional validation in T4?

2007-12-21 Thread Drew McAuliffe
The problem with the identity validator is that it doesn't seem to capture
the current value of the other control, which is the essential problem I'm
having. If you have 2 controls, and the second one uses an identity
validator to make sure it's the same as the first, if you change them both
at the same time, then the validator assumes the old value of the first
control rather than the new one. So if the controls were set to 1 and 2,
respectively, and on a submit you set them both to 3, the validator
doesn't pick up that the first control was set to 3 on that submit. So
validation fails, because it thinks its comparing 1 to 3 instead of the
current values, 3 to 3.
Am I missing something obvious? While debugging the Identity validator, it
is definitely not picking up the value in the referent control that was
submitted with the form. It's picking up its old value.

This is the crux of the problem I'm having. I don't know where in the course
of a form submit that new values as part of the submission are available to
other parts of the form. I'll look into the grouping example.

On Dec 21, 2007 7:44 AM, Steve Shucker [EMAIL PROTECTED] wrote:

 http://tapestry.apache.org/tapestry4.1/usersguide/validation.html

 http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/validator/Identity.html

 Look at the match/differ validators.  The cover the basic concept of a
 validator that acts on two components.  You can probably write a variant
 of the Identity class that will throw a ValidatorException is the
 referent is non-null and the validated control is null.

 Another approach would be to encapsulate the interrelated controls in a
 component to be validated as a group.  I think there's an example of
 this in Kent Tong's book.

 -Steve

 Drew McAuliffe wrote:
  I'm running into a problem with validators in T4. I have a situation
 where I
  sometimes need to validate a field on a form, but only if another field
 on
  the same form has a certain set of values. For example, a ship
 quantity
  field on an order form is only required if the order delivery method is
  shipment and not download (you don't have a ship quantity for an
 order
  that doesn't ship). Again, both fields are on the same form.
  Maybe I'm missing something but I don't know how to make the use of a
  validator conditional. I don't want to do manual validation in the
 submit
  method. I've tried setting the validators of the text field to a
 method on
  the page class that checks the field values, but it seems that the
  validation does not have access to the runtime selection made by the
 user.
  In other words, at the time my method tries to check if a validator is
  necessary, it is looking at old data and doesn't have access to the
 value
  the user was trying to submit. Something related to when in the page
 cycle
  validation is checked, I'm sure.
 
  Any ideas? This is for server-side validation, though of course
 client-side
  validation would be really nice too! (I imagine that would have to be
 using
  some sort of async callback method).
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Conditional validation in T4?

2007-12-21 Thread Andreas Andreou
looks like a bug then - you could add a JIRA

On Dec 21, 2007 11:51 PM, Drew McAuliffe [EMAIL PROTECTED] wrote:
 The problem with the identity validator is that it doesn't seem to capture
 the current value of the other control, which is the essential problem I'm
 having. If you have 2 controls, and the second one uses an identity
 validator to make sure it's the same as the first, if you change them both
 at the same time, then the validator assumes the old value of the first
 control rather than the new one. So if the controls were set to 1 and 2,
 respectively, and on a submit you set them both to 3, the validator
 doesn't pick up that the first control was set to 3 on that submit. So
 validation fails, because it thinks its comparing 1 to 3 instead of the
 current values, 3 to 3.
 Am I missing something obvious? While debugging the Identity validator, it
 is definitely not picking up the value in the referent control that was
 submitted with the form. It's picking up its old value.

 This is the crux of the problem I'm having. I don't know where in the course
 of a form submit that new values as part of the submission are available to
 other parts of the form. I'll look into the grouping example.


 On Dec 21, 2007 7:44 AM, Steve Shucker [EMAIL PROTECTED] wrote:

  http://tapestry.apache.org/tapestry4.1/usersguide/validation.html
 
  http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/validator/Identity.html
 
  Look at the match/differ validators.  The cover the basic concept of a
  validator that acts on two components.  You can probably write a variant
  of the Identity class that will throw a ValidatorException is the
  referent is non-null and the validated control is null.
 
  Another approach would be to encapsulate the interrelated controls in a
  component to be validated as a group.  I think there's an example of
  this in Kent Tong's book.
 
  -Steve
 
  Drew McAuliffe wrote:
   I'm running into a problem with validators in T4. I have a situation
  where I
   sometimes need to validate a field on a form, but only if another field
  on
   the same form has a certain set of values. For example, a ship
  quantity
   field on an order form is only required if the order delivery method is
   shipment and not download (you don't have a ship quantity for an
  order
   that doesn't ship). Again, both fields are on the same form.
   Maybe I'm missing something but I don't know how to make the use of a
   validator conditional. I don't want to do manual validation in the
  submit
   method. I've tried setting the validators of the text field to a
  method on
   the page class that checks the field values, but it seems that the
   validation does not have access to the runtime selection made by the
  user.
   In other words, at the time my method tries to check if a validator is
   necessary, it is looking at old data and doesn't have access to the
  value
   the user was trying to submit. Something related to when in the page
  cycle
   validation is checked, I'm sure.
  
   Any ideas? This is for server-side validation, though of course
  client-side
   validation would be really nice too! (I imagine that would have to be
  using
   some sort of async callback method).
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 




-- 
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Conditional validation

2007-06-22 Thread Michael Sims
Steve Shucker wrote:
 I need everything in one form
 because the checkbox states should be persisted even when the popup
 dialog is submitted.
[...]
 My options as I see them:
[...]
 - use a separate form with an async submit for the popup (may work,
 but then I'd have to return some javascript to submit the main page
 and redirect)

Why not use a separate form, and mark the properties used by your forms with the
@Persist annotation (either client or session)?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Conditional validation

2007-06-22 Thread Steve Shucker
Http only submits one set of form data.  If I have two forms, only the 
data from the form I submit is transmitted back to the server.  Tapestry 
wouldn't receive the other information I want to persist.  An async 
submit would get around this by not re-rendering the page to avoid 
losing the other state.


-Steve

Michael Sims wrote:

Steve Shucker wrote:
  

I need everything in one form
because the checkbox states should be persisted even when the popup
dialog is submitted.


[...]
  

My options as I see them:


[...]
  

- use a separate form with an async submit for the popup (may work,
but then I'd have to return some javascript to submit the main page
and redirect)



Why not use a separate form, and mark the properties used by your forms with the
@Persist annotation (either client or session)?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Conditional validation

2007-06-22 Thread Michael Sims
Steve Shucker wrote:
 Http only submits one set of form data.  If I have two forms, only the
 data from the form I submit is transmitted back to the server.
 Tapestry wouldn't receive the other information I want to persist.
 An async submit would get around this by not re-rendering the page to
 avoid losing the other state.

If you mark your properties as @Persist(client), Tapestry will include their 
state
as hidden form fields in all forms on your page, so no matter which form is
submitted, you won't lose the state of the others.  If you mark them as
@Persist(session) they will be stored in the HttpSession; either way they 
will be
persisted.  I'm not actually using this feature in my app yet, but I have 
tested it
and it does work...


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]