I'm still unsure why it happens, can you try following:
etract an interface with method getTf(); na put it outside components package for example: it.sailingweb.framework.web.InputWrapper Tapestry instruments classes in components,base,pages packages, and holds them in a separate ClassLoader... and problems like this can happen pretty easily... Davor Hrg On Jan 23, 2008 1:33 PM, riccaruf <[EMAIL PROTECTED]> wrote: > > Hi Davor, > we are developing an application with our own component, > and we are trying to validate a textfield like embedded component of our > component. > > Our own component is like that > > Sample.tml > > <input t:type="template/componenti/componentigenerici/SailingInput" > t:inputType="text" > t:value="value" > t:inputLabelText="Testo" > t:validator="sailingDataValidator" > /> > > In SailingInput.tml a simple tamplate like that > > <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > <t:if test="textType"> > > <t:label for="inputText1" /> > > <input t:type="textfield" > t:value="prop:value" > t:label="prop:labelText" > t:validate="prop:validator" > t:id="inputText1"/> > </t:if> > > </div> > > and in our component class SailingInput.java > > public class SailingInput extends AbstractField{ > ... > > @Parameter(required = false,defaultPrefix="validate",name="validator") > private FieldValidator validator; > > ... > } > > To obtain a FieldValidator in correct way I'd like tapestry do it for me, > so I'd like to use the validate defaultPrefix for my container component > parameter. > This means I have to extends AbstractField class that it is not strictly > necessary. > > In that way I could manage an instance of FieldValidator and bind it to my > embedded textfield component. > > But there is something strange that take me to try a workaround that make me > have the class clast of the post subject.(May be I miss something..) > The validator call the render method for my container component field > SailingInput BUT NOT for the contained component InputText, in that way the > server side validation works fine but not the client side because js find a > null field and broke! > So I've 2 kind of questions: > 1) why input text render method has not been called? > > 2)My ugly workaround (Yes I know ;) is the origin of this post: > > If the framework calls the render method of the validator only for my > container component, > I've tried to retrieve my contained component field element in the way I > show > > > public void render(Field field, Void constraintValue, MessageFormatter > formatter, MarkupWriter writer, > FormSupport formSupport) { > > System.out.println("### field:"+field); > Field inputField=field; > > if (field instanceof SailingInput){ > SailingInput si=(SailingInput)field; > inputField=si.getTf(); > } > > formSupport.addValidation(inputField, "test", > buildMessage(formatter, > field), null); > } > > And here we have the classcast exception. > > the packages are > > validator: > it.sailingweb.framework.web.components.utility.validators; > > component: > it.sailingweb.framework.web.components.template.componenti.componentigenerici > > pages: > it.sailingweb.framework.web.pages > > > hope to be clear. > > thanks for answer! > > -Rick > > > > > > > > Davor Hrg wrote: > > > > Class cast exceptions happen > > if you have non component classes inside components or pages packages... > > > > post some code and say what packages are those classes in... > > > > Davor Hrg > > > > On Jan 23, 2008 10:12 AM, riccaruf > > <[EMAIL PROTECTED]> wrote: > >> > >> Hi Dave thank you very mutch for your reply!! Oops..what I dummy I am! I > >> miss > >> something in the post preview :-(( , and > >> Yes yes my test was exactly in the way you write.... > >> > >> if (field instanceof MyInput).... > >> > >> But it doesn't work! > >> > >> The log messages show me that the instance tapestry pass me as parameter > >> is of my class but it seems not recognize it. Seems that the "instance > >> of" > >> can't work in the right way! > >> Is t5 class loader different in anything from the other? > >> Is because we can not instance directly a component so we can not access > >> in > >> any way > >> to its class ? > >> > >> I've triyed also the downcast but obvously a class cast explode on my > >> monitor ;). > >> > >> Please tell me what should happen... I can not understand. > >> > >> cheers > >> > >> -Rick > >> > >> > >> > >> > >> Dave.Derry wrote: > >> > > >> > I think your test is wrong. Don't you want > >> > > >> > if (field instanceof MyInput){ > >> > ? > >> > > >> > Dave > >> > > >> > We must begin not just to act, but to think, for there is no better > >> slave > >> > than the one who believes his slavery to be freedom, and we are in > >> > no greater peril than when we cannot see the chains on our minds > >> > because there are yet no chains on our feet. > >> > -- Michael Reid > >> > > >> > > >> > > >> > > >> > > >> > riccaruf > >> > <riccardo.ruffill > >> > [EMAIL PROTECTED] > >> To > >> > .com> users@tapestry.apache.org > >> > > >> cc > >> > 01/22/2008 12:09 > >> > PM > >> Subject > >> > t5 class cast > >> > > >> > Please respond to > >> > "Tapestry users" > >> > <[EMAIL PROTECTED] > >> > pache.org> > >> > > >> > > >> > > >> > > >> > > >> > > >> > > >> > Hi everybody, I've got this kind of method in my validator class > >> > > >> > public void render(Field field, Void constraintValue, > >> MessageFormatter > >> > formatter, MarkupWriter writer, > >> > FormSupport formSupport) { > >> > > >> > System.out.println("### field:"+field); > >> > Field inputField=field; > >> > if (field instanceof SailingInput){ > >> > MyInput si=(MyInput)field; > >> > inputField=si.get(); > >> > } > >> > formSupport.addValidation(inputField, "test", > >> > buildMessage(formatter, > >> > field), null); > >> > } > >> > > >> > this is the output > >> > > >> > ### field:[EMAIL PROTECTED] > >> > but the cast has never done. > >> > Any ideas ? > >> > > >> > thanks in advance. > >> > > >> > -Rick > >> > > >> > -- > >> > View this message in context: > >> > http://www.nabble.com/t5-class-cast-tp15023351p15023351.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] > >> > > >> > > >> > > >> > > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [EMAIL PROTECTED] > >> > For additional commands, e-mail: [EMAIL PROTECTED] > >> > > >> > > >> > > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/t5-class-cast-tp15023351p15037536.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] > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/t5-class-cast-tp15023351p15040746.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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]