Re: Tap 4 Validator questions
Dennis, thanks for your reply. Your hint and some experimentation made me realize that the right place to initialize the bean parameters is in the annotation. "validators=validators:" actually does work: @Bean(initializer = "max=2000,message=%my-resource-bundle-error-message-key") public abstract Max getMyMaxValidator(); @Component(type="TextField", bindings = { "displayName=message:my-label", "value=myfieldval", "validators=validators:$myMaxValidator", "translator=translator:number"}) public abstract IFormComponent getMyField(); Thanks, Julian - Original Message From: Dennis Sinelnikov <[EMAIL PROTECTED]> To: users@tapestry.apache.org Sent: Friday, November 10, 2006 3:18:32 PM Subject: Re: Tap 4 Validator questions I think your problem is in using validators: prefix in "validators=validators:" That tells tapestry, that your listing validators. However, $myMaxValidator is actually a bean (your custom validator). Thus, you need to use bean: prefix. "validators=bean:.." If you want to use more than 1 validator on 1 component, you could do something along these lines. This is what I did in my .page, should give you an idea on what to do. ... The answer to your second question, I'm not 100% sure why it was done. It appears that org.apache.tapestry.valid.* was written pre tapestry 4.0 and org.apache.tapestry.form.validator.* was written by Howard starting tapestry 4.0+. I believe this was done for Hivemind reasons and tighter integration with components (i.e. TextField). These packages use different delegates, and that is why you're running into issues. Perhaps one of the tapestry developers can shed more light on why this was done. hth, Dennis Julian Sinai wrote: > Hi > > I'm a bit confused about validators in Tapestry 4.0.2. The doc says the > following ought to work: > > import org.apache.tapestry.annotations.*; > import org.apache.tapestry.form.validator.Max; > import org.apache.tapestry.form.validator.Validator; > > @ComponentClass(allowInformalParameters = false, allowBody = true) > public abstract class EditEventForm extends BaseComponent > { > @Bean(Max.class) > public abstract Validator getMyMaxValidator(); > > public abstract int getMyfieldval(); > > @Component(type="TextField", bindings = > { "displayName=message:my-label", "value=myfieldval", > > "validators=validators:$myMaxValidator,max=2000[%my-resource-bundle-error-message-key]", > "translator=translator:number"}) > public abstract IFormComponent getMyField(); > ... > } > > The fields display fine and work fine, however, validation doesn't work right > because the max value and message don't get filled in. Why? > > Also, what's the difference between: > > org.apache.tapestry.valid.*Validator > org.apache.tapestry.form.validator.* > > It seems only org.apache.tapestry.form.validator.* will work. For example, > if I try to use IntValidator, I get an exception that it can't be > instantiated. > > Any help is appreciated. > Thanks, > Julian > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
3.0.4 and repetitive method name/signature problem (class enhancement)
I work on a project that is using Tapestry 3. We're currently working on version 4 of this product, and in this release we have upgraded to version 3.0.4 of Tapestry. In every version of our product we have done some amount of load testing as part of our quality assurance process. In this release, we've started seeing this sort of exception a lot during load (and occasionally in our functional) testing. Tapestry exception java.lang.Throwable: Unable to define class org.apache.tapestry.link.PageLink$Enhance_32: org/apache/tapestry/ link/PageLink$Enhance_32 (Repetitive method name/signature) at org.apache.tapestry.enhance.EnhancedClassLoader.defineClass (EnhancedClassLoader.java:55) at org.apache.tapestry.enhance.javassist.EnhancedClass.createEnhancedSubcla ss(EnhancedClass.java:133) at org.apache.tapestry.enhance.ComponentClassFactory.createEnhancedSubclass (ComponentClassFactory.java:336) at org.apache.tapestry.enhance.DefaultComponentClassEnhancer.constructCompo nentClass(DefaultComponentClassEnhancer.java:139) at org.apache.tapestry.enhance.DefaultComponentClassEnhancer.getEnhancedCla ss(DefaultComponentClassEnhancer.java:94) at org.apache.tapestry.pageload.PageLoader.instantiateComponent (PageLoader.java:603) This doesn't always seem to happen on the same page, and it isn't always the same component that throws the exception. (Here it is PageLink, I've also seen Any and Body throw this). I've been scratching my head on this for a while, trying to figure out why we hadn't seen this in previous releases... Then I remembered we switch to 3.0.4, and I decided to look into the differences. I found something in the DefaultComponentClassEnhancer which has changed, and I'd be interested in hearing if anybody believes this could cause my problem. Specifically the method getEnhancedClass has changed from the following in 3.0.3 public Class getEnhancedClass(IComponentSpecification specification, String className) { Class result = getCachedClass(specification); if (result == null) { synchronized(this) { result = getCachedClass(specification); if (result == null) { result = constructComponentClass(specification, className); storeCachedClass(specification, result); } } } return result; } to this in 3.0.4 public Class getEnhancedClass(IComponentSpecification specification, String className) { synchronized(specification) { Class result = getCachedClass(specification); if (result == null) { result = constructComponentClass(specification, className); storeCachedClass(specification, result); } return result; } } Now, my understanding of the tapestry internals has plenty of holes in it, so I don't know if this can be related to my problem or not, but the circumstances are such that it feels like a likely candidate. To try to test this theory myself, I have created a custom ComponentClassEnhancer implementation which basically reverts back to the 3.0.3 synchronization style - however, I haven't had an opportunity to get it into a load test environment yet. I should be able to do this sometime early this week. I'd love to hear from any developers who feel they can verify that this is my problem, or debunk it totally. :) Thanks much, Jeff Poetker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple 'hidden' fields for the same "for" loop
Hello, Just was curious if the multiple entries for 'prompts' was a cause for concern? 'prompts' is the id of a For loop. I am puzzled why it would appear twice. I am using Tapestry 4.1 downloaded October 15th or so. Thanks, -Ryan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: object injection and class cast
The object you get is actually a proxy to the actual service implementation. The dynamic proxy only knows that it needs to support the javax.servlet.Filter interface, so that's all it supports. You can't downcast it to the implementation class. What you can do is come up with your own service interface which extends javax.servlet.Filter and your implementation class can implement that. You'd have to use that interface to "talk to" your service object. p.s. Alternatively, there is such a thing as bean services (the service interface is the bean class), but I don't suggest using them. It's better to front your services with an interface (which is what we have to fabricate at runtime via Javassist to support bean services). On 11/11/06, Robin Ericsson <[EMAIL PROTECTED]> wrote: Hi, This is really a hivemind question, but it's my tapestry usage that probably is wrong :) My service looks like this: I inject it in tapestry like this: @InjectObject("service:bwatch.FormProcessingFilter") public abstract Filter getProcessingFilter(); But when I cast it to my class which I know it is, I get a ClassCastException. FormProcessingFilter filter = (FormProcessingFilter) getProcessingFilter(); What am I doing wrong and how should I solve it? :) -- regards, Robin - 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]
object injection and class cast
Hi, This is really a hivemind question, but it's my tapestry usage that probably is wrong :) My service looks like this: I inject it in tapestry like this: @InjectObject("service:bwatch.FormProcessingFilter") public abstract Filter getProcessingFilter(); But when I cast it to my class which I know it is, I get a ClassCastException. FormProcessingFilter filter = (FormProcessingFilter) getProcessingFilter(); What am I doing wrong and how should I solve it? :) -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]