You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by poletn23 <im...@gmail.com> on 2012/03/22 22:04:17 UTC
onValidate behave strange
I have problem with onValidate method. what's happens!? When I submit form,
onValidate method invoked, but it happens nothing. Operation continue to run
and tapestry report an error. When i do backward in my browser and refresh
page i have got desired results, my customize information message.
Code:
- tml:
<t:beaneditform t:id="izmenaKupca" object="telefonKupca"
exclude="brojTelefona" add="ime, prezime, adresa"
submitlabel="message:create/updateiz">
<t:parameter name="ime">
<t:label t:for="ime">Ime Kupca</t:label>
<t:textfield t:value="telefonKupca.kupac.ime" t:id="ime3"/>
</t:parameter>
<t:parameter name="prezime">
<t:label t:for="prezime"/>
<t:textfield t:value="telefonKupca.kupac.prezime"
t:id="prezime3"/>
</t:parameter>
<t:parameter name="adresa">
<t:label t:for="adresa"/>
<t:textfield t:value="telefonKupca.kupac.adresa"
t:id="adresa3"/>
</t:parameter>
</t:beaneditform>
- java:
void onValidateFromTelefonKupca() throws ValidationException
{
Telefonkupca tk = (Telefonkupca) service.find(Telefonkupca.class,
telefonKupca.getBrojTelefona());
if(tk!=null){
throw new ValidationException("Vec postoji");
}
}
.
.
.
Object onSubmitFromTelefonKupca(){
service.persist(telefonKupca);
return index;
}
In this example I want to get message when try to insert customer who
already exists in database. But when i try to insert cusomer with id thats
already exist, tapestry report error "Duplicate entry '0653235453' for key
'PRIMARY'".... I think that validation system will stop execution of
operation... Can somebody explain me where is error?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/onValidate-behave-strange-tp5587786p5587786.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: onValidate behave strange
Posted by poletn23 <im...@gmail.com>.
Sorry, my mistake. I wrote wrong beaneditform.
*TML*
<t:beaneditform <b>t:id="telefonKupca*" object="telefonKupca" add="ime,
prezime, adresa" submitlabel="message:create/update">
<t:errors/>
<t:parameter name="brojTelefona">
<t:label for="brojTelefona"/>
<t:textfield t:id="brojTelefona"
t:value="telefonKupca.brojTelefona" t:validate="required" />
</t:parameter>
<t:parameter name="ime">
<t:label t:for="ime">Ime Kupca</t:label>
<t:textfield t:value="telefonKupca.kupac.ime" t:id="ime"
t:validate="required"/>
</t:parameter>
<t:parameter name="prezime">
<t:label t:for="prezime"/>
<t:textfield t:value="telefonKupca.kupac.prezime"
t:id="prezime"/>
</t:parameter>
<t:parameter name="adresa">
<t:label t:for="adresa"/>
<t:textfield t:value="telefonKupca.kupac.adresa" t:id="adresa"/>
</t:parameter>
</t:beaneditform>
JAVA
void onValidateFromTelefonKupca() throws ValidationException
> {
> Telefonkupca tk = (Telefonkupca) service.find(Telefonkupca.class,
> telefonKupca.getBrojTelefona());
> if(tk!=null){
> throw new ValidationException("Vec postoji");
> }
> }
>
> .
> .
> .
> Object onSubmitFromTelefonKupca(){
> service.persist(telefonKupca);
> return index;
> }
--
View this message in context: http://tapestry.1045711.n5.nabble.com/onValidate-behave-strange-tp5587786p5588624.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: onValidate behave strange
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
I don't think your validate method was ever called because it refers to a
component t:id (telefonKupca) which doesn't exist. Have you tried
onValidateFromIzmenaKupca?
On Thu, 22 Mar 2012 18:04:17 -0300, poletn23 <im...@gmail.com> wrote:
> I have problem with onValidate method. what's happens!? When I submit
> form,
> onValidate method invoked, but it happens nothing. Operation continue to
> run
> and tapestry report an error. When i do backward in my browser and
> refresh
> page i have got desired results, my customize information message.
>
> Code:
> - tml:
>
> <t:beaneditform t:id="izmenaKupca" object="telefonKupca"
> exclude="brojTelefona" add="ime, prezime, adresa"
> submitlabel="message:create/updateiz">
> <t:parameter name="ime">
> <t:label t:for="ime">Ime Kupca</t:label>
> <t:textfield t:value="telefonKupca.kupac.ime" t:id="ime3"/>
> </t:parameter>
> <t:parameter name="prezime">
> <t:label t:for="prezime"/>
> <t:textfield t:value="telefonKupca.kupac.prezime"
> t:id="prezime3"/>
> </t:parameter>
> <t:parameter name="adresa">
> <t:label t:for="adresa"/>
> <t:textfield t:value="telefonKupca.kupac.adresa"
> t:id="adresa3"/>
> </t:parameter>
> </t:beaneditform>
>
> - java:
>
> void onValidateFromTelefonKupca() throws ValidationException
> {
> Telefonkupca tk = (Telefonkupca) service.find(Telefonkupca.class,
> telefonKupca.getBrojTelefona());
> if(tk!=null){
> throw new ValidationException("Vec postoji");
> }
> }
>
> .
> .
> .
> Object onSubmitFromTelefonKupca(){
> service.persist(telefonKupca);
> return index;
> }
>
> In this example I want to get message when try to insert customer who
> already exists in database. But when i try to insert cusomer with id
> thats
> already exist, tapestry report error "Duplicate entry '0653235453' for
> key
> 'PRIMARY'".... I think that validation system will stop execution of
> operation... Can somebody explain me where is error?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/onValidate-behave-strange-tp5587786p5587786.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: onValidate behave strange
Posted by Muhammad Gelbana <m....@gmail.com>.
On your validation method, why are you throwing an exception ?! You should
have in injected form component and record an error in it.
@InjectComponent
private Form *componentId*;
Then in your validation method:
*componentId* .recordError (Or something similar)
Also using an @OnEvent annotation on event methods makes it a lot precise,
or at least I find it so.
Good luck.
On Sat, Mar 24, 2012 at 2:01 PM, Borko Djurovic <dj...@gmail.com>wrote:
> Replace onSubmit... with onSuccess... The main difference is that onSuccess
> handler will be called only when validation is passed. Handler onSubmit is
> called every time you submit form.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/onValidate-behave-strange-tp5587786p5591585.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
*Regards,*
*Muhammad Gelbana
Java Developer*
Re: onValidate behave strange
Posted by Borko Djurovic <dj...@gmail.com>.
Replace onSubmit... with onSuccess... The main difference is that onSuccess
handler will be called only when validation is passed. Handler onSubmit is
called every time you submit form.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/onValidate-behave-strange-tp5587786p5591585.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org