You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "squallmat ." <sq...@gmail.com> on 2014/07/16 16:05:30 UTC

ajaxformloop and localization

I'm using an ajaxformloop component, that works really well.

But my webapp is developed in two languages : english and french, and when
I tried to switch to another localization the added rows disappear,
and if i switch back to the first langauge the rows are reappearing and are
empty.

Is there methods to make ajaxformloop working in case of localization
switching ?

Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
And while I'm here,
is it possible to change the text of "Add row" for what we want ?


2014-07-16 16:05 GMT+02:00 squallmat . <sq...@gmail.com>:

> I'm using an ajaxformloop component, that works really well.
>
> But my webapp is developed in two languages : english and french, and when
> I tried to switch to another localization the added rows disappear,
> and if i switch back to the first langauge the rows are reappearing and
> are empty.
>
> Is there methods to make ajaxformloop working in case of localization
> switching ?
>

Re: ajaxformloop and localization

Posted by Geoff Callender <ge...@gmail.com>.
I meant "in onValidateFromForm()", not "in onSubmit()". Alternatively, detect which submit was pressed like this:

	http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/multiplesubmits1


On 18 Jul 2014, at 8:02 pm, Geoff Callender <ge...@gmail.com> wrote:

> IMHO, you should take a fresh look at the user experience. If you choose the more natural flow of asking the user to choose a language *before* presenting them with any forms, then the flow becomes natural and all the difficulties disappear.
> 
> If, however, you proceed with the way you describe, then the inescapable fact is that when you switch language, the separate form on the page must be submitted and it must include info about the language you're switching to. Here's a way:
> 
> * in each form, include a hidden field, switchLanguage.
> * in each form, include a hidden Submit with mode="cancel".
> * in the component layout, you don't need Form, Submit, EventLink, or ActionLink in the component layout. Instead, use <a href="#"> links.
> * in the component layout, require javascript that, on click of a switcher link:
> 	* finds the hidden field, switchLanguage, and populates it; and
> 	* finds the hidden Submit with mode="cancel" and clicks it.
> * server-side, in onSubmit, if switchLanguage is not null then you know to switch the language.
> 
> If however, the component layout is around multiple forms, then things get tricky. It might work if it AJAX-submits each one.
> 
> HTH,
> 
> Geoff
> 
> On 18 Jul 2014, at 1:49 am, squallmat . <sq...@gmail.com> wrote:
> 
>> The language switchers are in a component layout including the pages where
>> there is the forms. And I don't want (and the client too :p) to change the
>> presentation.
>> 
>> 
>> 2014-07-17 17:34 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
>> :
>> 
>>> On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . <sq...@gmail.com>
>>> wrote:
>>> 
>>> What is still stucking me is that language switching, I can't do it with
>>>> form because we can't nest them.
>>>> 
>>> 
>>> Put the language switcher inside the form. No need to nest forms. Or add
>>> some JavaScript to disable the language switcher when your form has
>>> something typed on them.
>>> 
>>> 
>>> Is there a way in an actionlink to force persisting of the properties of
>>>> a page ?
>>>> 
>>> 
>>> I'm sorry, this questions doesn't make much sense, as what controls the
>>> persistence of a page fields are annotations in the fields themselves.
>>> 
>>> 
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Tapestry, Java and Hibernate consultant and developer
>>> http://machina.com.br
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>>> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by Geoff Callender <ge...@gmail.com>.
IMHO, you should take a fresh look at the user experience. If you choose the more natural flow of asking the user to choose a language *before* presenting them with any forms, then the flow becomes natural and all the difficulties disappear.

If, however, you proceed with the way you describe, then the inescapable fact is that when you switch language, the separate form on the page must be submitted and it must include info about the language you're switching to. Here's a way:

* in each form, include a hidden field, switchLanguage.
* in each form, include a hidden Submit with mode="cancel".
* in the component layout, you don't need Form, Submit, EventLink, or ActionLink in the component layout. Instead, use <a href="#"> links.
* in the component layout, require javascript that, on click of a switcher link:
	* finds the hidden field, switchLanguage, and populates it; and
	* finds the hidden Submit with mode="cancel" and clicks it.
* server-side, in onSubmit, if switchLanguage is not null then you know to switch the language.

If however, the component layout is around multiple forms, then things get tricky. It might work if it AJAX-submits each one.

HTH,

Geoff

On 18 Jul 2014, at 1:49 am, squallmat . <sq...@gmail.com> wrote:

> The language switchers are in a component layout including the pages where
> there is the forms. And I don't want (and the client too :p) to change the
> presentation.
> 
> 
> 2014-07-17 17:34 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
> :
> 
>> On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . <sq...@gmail.com>
>> wrote:
>> 
>> What is still stucking me is that language switching, I can't do it with
>>> form because we can't nest them.
>>> 
>> 
>> Put the language switcher inside the form. No need to nest forms. Or add
>> some JavaScript to disable the language switcher when your form has
>> something typed on them.
>> 
>> 
>> Is there a way in an actionlink to force persisting of the properties of
>>> a page ?
>>> 
>> 
>> I'm sorry, this questions doesn't make much sense, as what controls the
>> persistence of a page fields are annotations in the fields themselves.
>> 
>> 
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
The language switchers are in a component layout including the pages where
there is the forms. And I don't want (and the client too :p) to change the
presentation.


2014-07-17 17:34 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . <sq...@gmail.com>
> wrote:
>
>  What is still stucking me is that language switching, I can't do it with
>> form because we can't nest them.
>>
>
> Put the language switcher inside the form. No need to nest forms. Or add
> some JavaScript to disable the language switcher when your form has
> something typed on them.
>
>
>  Is there a way in an actionlink to force persisting of the properties of
>> a page ?
>>
>
> I'm sorry, this questions doesn't make much sense, as what controls the
> persistence of a page fields are annotations in the fields themselves.
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: ajaxformloop and localization

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . <sq...@gmail.com>  
wrote:

> What is still stucking me is that language switching, I can't do it with
> form because we can't nest them.

Put the language switcher inside the form. No need to nest forms. Or add  
some JavaScript to disable the language switcher when your form has  
something typed on them.

> Is there a way in an actionlink to force persisting of the properties of  
> a page ?

I'm sorry, this questions doesn't make much sense, as what controls the  
persistence of a page fields are annotations in the fields themselves.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
Thanks Geoff, I already found how to change the Add row :)

What is still stucking me is that language switching, I can't do it with
form because we can't nest them.
Is there a way in an actionlink to force persisting of the properties of a
page ?


2014-07-17 16:10 GMT+02:00 Geoff Callender <
geoff.callender.jumpstart@gmail.com>:

> A form will only submit what it contains. You need a single form that
> contains all your "switch" submits, the AjaxFormLoop, and anything else you
> don't want to lose.
>
> Regarding changing "Add a Row", it's just text in this example...
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1
>
> ...which you could replace with something like ${message:add-a-row-label}
> and a corresponding entry in app.properties or your localisation solution...
>
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bymessagecatalog
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bytemplate
>
> Geoff
>
> On 17 Jul 2014, at 11:32 pm, squallmat . <sq...@gmail.com> wrote:
>
> > hello Geoff,
> > I just changed my actionlinks to form-submit :
> >
> > <li style="float: right">
> > <t:Form t:id="englishForm">
> > <t:Submit t:mode="UNCONDITIONAL"
> > t:image="asset:classpath:layout/images/en.jpg" class="imgflag" alt="en"/>
> > </t:Form>
> > </li>
> > <li style="float: right; border: none">
> > <t:Form t:id="frenchForm">
> > <t:Submit t:mode="UNCONDITIONAL"
> > t:image="asset:classpath:layout/images/fr.jpg" class="imgflag" alt="fr"/>
> > </t:Form>
> > </li>
> >
> >
> > @Component(id = "englishForm")
> > private Form englishForm;
> >
> > @Component(id = "frenchForm")
> > private Form frenchForm;
> >
> > @OnEvent(value = EventConstants.SUCCESS, component = "englishForm")
> > public Object onSuccess() {
> > persistentLocale.set(new Locale("en"));
> > return null;
> > }
> >
> > @OnEvent(value = EventConstants.SUCCESS, component = "frenchForm")
> > public Object onSuccesstwo() {
> > persistentLocale.set(new Locale("fr"));
> > return null;
> > }
> >
> >
> > But that still continue to do the same thing. Is it necessary that my
> forms
> > with submit switching language covers the field that we want persisted ?
> > Because the switching language links/submit are in component layout.
> > Is there another way/method/trick to achieve what I want ?
> >
> >
> > 2014-07-17 12:36 GMT+02:00 Geoff Callender <
> > geoff.callender.jumpstart@gmail.com>:
> >
> >> Yes, to switch language the client (ie. the browser) must request the
> >> server to render the page in the new language. If the request to switch
> is
> >> from an EventLink or ActionLink, then values entered into the form will
> be
> >> lost. That is because they use HTTP GET. If your request to switch is
> from
> >> a Submit, then values entered into the form will be sent to the server.
> >> That is because it uses HTTP POST.
> >>
> >> Remember that by default the server-side is stateless (and that is a
> good
> >> thing). @Persist tells the server to keep state: it says keep a copy of
> the
> >> last rendered value of something. (By default it keeps that copy in the
> >> session, but there are options to keep it as a cookie, or in the URL, or
> >> wherever you like).
> >>
> >> If your user really does want to switch language while working in a form
> >> (which is a very unusual use case) then try Submit with mode="cancel" or
> >> mode="unconditional".
> >>
> >>
> >>
> http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html
> >>
> >> On 17 Jul 2014, at 8:26 pm, squallmat . <sq...@gmail.com> wrote:
> >>
> >>> I added @Persist on a field in my form, it doesn't persist if switch
> >>> locale. But if I try to submit (onSubmit not implemented in the .java)
> >> then
> >>> the field become really persistente, even if I switch locale  the field
> >>> stay filled.
> >>> Why this behavior ? How can I get this persistency between locale
> >> switching
> >>> without having to "fail-submit" before ?
> >>>
> >>>
> >>> 2014-07-17 10:23 GMT+02:00 squallmat . <sq...@gmail.com>:
> >>>
> >>>> I added @Persist on both source and value, now fields persist between
> >>>> languages.
> >>>> But localization switching reload the page, so I assume if I want the
> >>>> field that were filled to stay filled at language switching I need to
> >> put
> >>>> on all my Property with @Persist and refill each field in SetupRender,
> >>>> right ?
> >>>>
> >>>> Is this possible to have localization switchin without page reloading,
> >> and
> >>>> only the labels "ajaxly" updated ?
> >>>>
> >>>>
> >>>> 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <
> >>>> thiagohp@gmail.com>:
> >>>>
> >>>> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
> >>>>> wrote:
> >>>>>
> >>>>> Still, in the Client entity that i will persist at the submit, I
> store
> >> my
> >>>>>> contacts in it :
> >>>>>> // when adding a contact row
> >>>>>> Object onAddRowFromContacts() {
> >>>>>> ContactDto contactDto = new ContactDto();
> >>>>>>
> >>>>>> clientDto.getContactList().add(contactDto);
> >>>>>>
> >>>>>> return contactDto;
> >>>>>> }
> >>>>>>
> >>>>>> Is there a way to achieve what I want, keep my rows at language
> >> switching
> >>>>>> without persisting in db ?
> >>>>>>
> >>>>>
> >>>>> Look at the @Persist annotation. Session persistence. Again, it's
> >>>>> completely unrelated to language switching.
> >>>>>
> >>>>> @Persist
> >>>>> private ContactDto contactDto;
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Thiago H. de Paula Figueiredo
> >>>>> Tapestry, Java and Hibernate consultant and developer
> >>>>> http://machina.com.br
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>
> >>>>>
> >>>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: ajaxformloop and localization

Posted by Geoff Callender <ge...@gmail.com>.
A form will only submit what it contains. You need a single form that contains all your "switch" submits, the AjaxFormLoop, and anything else you don't want to lose.

Regarding changing "Add a Row", it's just text in this example...

	http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1

...which you could replace with something like ${message:add-a-row-label} and a corresponding entry in app.properties or your localisation solution...

	http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bymessagecatalog
	http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bytemplate

Geoff

On 17 Jul 2014, at 11:32 pm, squallmat . <sq...@gmail.com> wrote:

> hello Geoff,
> I just changed my actionlinks to form-submit :
> 
> <li style="float: right">
> <t:Form t:id="englishForm">
> <t:Submit t:mode="UNCONDITIONAL"
> t:image="asset:classpath:layout/images/en.jpg" class="imgflag" alt="en"/>
> </t:Form>
> </li>
> <li style="float: right; border: none">
> <t:Form t:id="frenchForm">
> <t:Submit t:mode="UNCONDITIONAL"
> t:image="asset:classpath:layout/images/fr.jpg" class="imgflag" alt="fr"/>
> </t:Form>
> </li>
> 
> 
> @Component(id = "englishForm")
> private Form englishForm;
> 
> @Component(id = "frenchForm")
> private Form frenchForm;
> 
> @OnEvent(value = EventConstants.SUCCESS, component = "englishForm")
> public Object onSuccess() {
> persistentLocale.set(new Locale("en"));
> return null;
> }
> 
> @OnEvent(value = EventConstants.SUCCESS, component = "frenchForm")
> public Object onSuccesstwo() {
> persistentLocale.set(new Locale("fr"));
> return null;
> }
> 
> 
> But that still continue to do the same thing. Is it necessary that my forms
> with submit switching language covers the field that we want persisted ?
> Because the switching language links/submit are in component layout.
> Is there another way/method/trick to achieve what I want ?
> 
> 
> 2014-07-17 12:36 GMT+02:00 Geoff Callender <
> geoff.callender.jumpstart@gmail.com>:
> 
>> Yes, to switch language the client (ie. the browser) must request the
>> server to render the page in the new language. If the request to switch is
>> from an EventLink or ActionLink, then values entered into the form will be
>> lost. That is because they use HTTP GET. If your request to switch is from
>> a Submit, then values entered into the form will be sent to the server.
>> That is because it uses HTTP POST.
>> 
>> Remember that by default the server-side is stateless (and that is a good
>> thing). @Persist tells the server to keep state: it says keep a copy of the
>> last rendered value of something. (By default it keeps that copy in the
>> session, but there are options to keep it as a cookie, or in the URL, or
>> wherever you like).
>> 
>> If your user really does want to switch language while working in a form
>> (which is a very unusual use case) then try Submit with mode="cancel" or
>> mode="unconditional".
>> 
>> 
>> http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html
>> 
>> On 17 Jul 2014, at 8:26 pm, squallmat . <sq...@gmail.com> wrote:
>> 
>>> I added @Persist on a field in my form, it doesn't persist if switch
>>> locale. But if I try to submit (onSubmit not implemented in the .java)
>> then
>>> the field become really persistente, even if I switch locale  the field
>>> stay filled.
>>> Why this behavior ? How can I get this persistency between locale
>> switching
>>> without having to "fail-submit" before ?
>>> 
>>> 
>>> 2014-07-17 10:23 GMT+02:00 squallmat . <sq...@gmail.com>:
>>> 
>>>> I added @Persist on both source and value, now fields persist between
>>>> languages.
>>>> But localization switching reload the page, so I assume if I want the
>>>> field that were filled to stay filled at language switching I need to
>> put
>>>> on all my Property with @Persist and refill each field in SetupRender,
>>>> right ?
>>>> 
>>>> Is this possible to have localization switchin without page reloading,
>> and
>>>> only the labels "ajaxly" updated ?
>>>> 
>>>> 
>>>> 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <
>>>> thiagohp@gmail.com>:
>>>> 
>>>> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
>>>>> wrote:
>>>>> 
>>>>> Still, in the Client entity that i will persist at the submit, I store
>> my
>>>>>> contacts in it :
>>>>>> // when adding a contact row
>>>>>> Object onAddRowFromContacts() {
>>>>>> ContactDto contactDto = new ContactDto();
>>>>>> 
>>>>>> clientDto.getContactList().add(contactDto);
>>>>>> 
>>>>>> return contactDto;
>>>>>> }
>>>>>> 
>>>>>> Is there a way to achieve what I want, keep my rows at language
>> switching
>>>>>> without persisting in db ?
>>>>>> 
>>>>> 
>>>>> Look at the @Persist annotation. Session persistence. Again, it's
>>>>> completely unrelated to language switching.
>>>>> 
>>>>> @Persist
>>>>> private ContactDto contactDto;
>>>>> 
>>>>> 
>>>>> --
>>>>> Thiago H. de Paula Figueiredo
>>>>> Tapestry, Java and Hibernate consultant and developer
>>>>> http://machina.com.br
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>> 
>>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 17 Jul 2014 10:32:32 -0300, squallmat . <sq...@gmail.com>  
wrote:

> But that still continue to do the same thing. Is it necessary that my  
> forms
> with submit switching language covers the field that we want persisted ?

Yep. Otherwise, the field values you want persisted aren't submitted.  
That's basic HTML knowledge.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
hello Geoff,
I just changed my actionlinks to form-submit :

<li style="float: right">
<t:Form t:id="englishForm">
<t:Submit t:mode="UNCONDITIONAL"
t:image="asset:classpath:layout/images/en.jpg" class="imgflag" alt="en"/>
</t:Form>
</li>
<li style="float: right; border: none">
<t:Form t:id="frenchForm">
<t:Submit t:mode="UNCONDITIONAL"
t:image="asset:classpath:layout/images/fr.jpg" class="imgflag" alt="fr"/>
</t:Form>
</li>


@Component(id = "englishForm")
private Form englishForm;

@Component(id = "frenchForm")
private Form frenchForm;

@OnEvent(value = EventConstants.SUCCESS, component = "englishForm")
public Object onSuccess() {
persistentLocale.set(new Locale("en"));
return null;
}

@OnEvent(value = EventConstants.SUCCESS, component = "frenchForm")
public Object onSuccesstwo() {
persistentLocale.set(new Locale("fr"));
return null;
}


But that still continue to do the same thing. Is it necessary that my forms
with submit switching language covers the field that we want persisted ?
Because the switching language links/submit are in component layout.
Is there another way/method/trick to achieve what I want ?


2014-07-17 12:36 GMT+02:00 Geoff Callender <
geoff.callender.jumpstart@gmail.com>:

> Yes, to switch language the client (ie. the browser) must request the
> server to render the page in the new language. If the request to switch is
> from an EventLink or ActionLink, then values entered into the form will be
> lost. That is because they use HTTP GET. If your request to switch is from
> a Submit, then values entered into the form will be sent to the server.
> That is because it uses HTTP POST.
>
> Remember that by default the server-side is stateless (and that is a good
> thing). @Persist tells the server to keep state: it says keep a copy of the
> last rendered value of something. (By default it keeps that copy in the
> session, but there are options to keep it as a cookie, or in the URL, or
> wherever you like).
>
> If your user really does want to switch language while working in a form
> (which is a very unusual use case) then try Submit with mode="cancel" or
> mode="unconditional".
>
>
> http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html
>
> On 17 Jul 2014, at 8:26 pm, squallmat . <sq...@gmail.com> wrote:
>
> > I added @Persist on a field in my form, it doesn't persist if switch
> > locale. But if I try to submit (onSubmit not implemented in the .java)
> then
> > the field become really persistente, even if I switch locale  the field
> > stay filled.
> > Why this behavior ? How can I get this persistency between locale
> switching
> > without having to "fail-submit" before ?
> >
> >
> > 2014-07-17 10:23 GMT+02:00 squallmat . <sq...@gmail.com>:
> >
> >> I added @Persist on both source and value, now fields persist between
> >> languages.
> >> But localization switching reload the page, so I assume if I want the
> >> field that were filled to stay filled at language switching I need to
> put
> >> on all my Property with @Persist and refill each field in SetupRender,
> >> right ?
> >>
> >> Is this possible to have localization switchin without page reloading,
> and
> >> only the labels "ajaxly" updated ?
> >>
> >>
> >> 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <
> >> thiagohp@gmail.com>:
> >>
> >> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
> >>> wrote:
> >>>
> >>> Still, in the Client entity that i will persist at the submit, I store
> my
> >>>> contacts in it :
> >>>> // when adding a contact row
> >>>> Object onAddRowFromContacts() {
> >>>> ContactDto contactDto = new ContactDto();
> >>>>
> >>>> clientDto.getContactList().add(contactDto);
> >>>>
> >>>> return contactDto;
> >>>> }
> >>>>
> >>>> Is there a way to achieve what I want, keep my rows at language
> switching
> >>>> without persisting in db ?
> >>>>
> >>>
> >>> Look at the @Persist annotation. Session persistence. Again, it's
> >>> completely unrelated to language switching.
> >>>
> >>> @Persist
> >>> private ContactDto contactDto;
> >>>
> >>>
> >>> --
> >>> Thiago H. de Paula Figueiredo
> >>> Tapestry, Java and Hibernate consultant and developer
> >>> http://machina.com.br
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: ajaxformloop and localization

Posted by Geoff Callender <ge...@gmail.com>.
Yes, to switch language the client (ie. the browser) must request the server to render the page in the new language. If the request to switch is from an EventLink or ActionLink, then values entered into the form will be lost. That is because they use HTTP GET. If your request to switch is from a Submit, then values entered into the form will be sent to the server. That is because it uses HTTP POST.

Remember that by default the server-side is stateless (and that is a good thing). @Persist tells the server to keep state: it says keep a copy of the last rendered value of something. (By default it keeps that copy in the session, but there are options to keep it as a cookie, or in the URL, or wherever you like).

If your user really does want to switch language while working in a form (which is a very unusual use case) then try Submit with mode="cancel" or mode="unconditional". 

	http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html

On 17 Jul 2014, at 8:26 pm, squallmat . <sq...@gmail.com> wrote:

> I added @Persist on a field in my form, it doesn't persist if switch
> locale. But if I try to submit (onSubmit not implemented in the .java) then
> the field become really persistente, even if I switch locale  the field
> stay filled.
> Why this behavior ? How can I get this persistency between locale switching
> without having to "fail-submit" before ?
> 
> 
> 2014-07-17 10:23 GMT+02:00 squallmat . <sq...@gmail.com>:
> 
>> I added @Persist on both source and value, now fields persist between
>> languages.
>> But localization switching reload the page, so I assume if I want the
>> field that were filled to stay filled at language switching I need to put
>> on all my Property with @Persist and refill each field in SetupRender,
>> right ?
>> 
>> Is this possible to have localization switchin without page reloading, and
>> only the labels "ajaxly" updated ?
>> 
>> 
>> 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <
>> thiagohp@gmail.com>:
>> 
>> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
>>> wrote:
>>> 
>>> Still, in the Client entity that i will persist at the submit, I store my
>>>> contacts in it :
>>>> // when adding a contact row
>>>> Object onAddRowFromContacts() {
>>>> ContactDto contactDto = new ContactDto();
>>>> 
>>>> clientDto.getContactList().add(contactDto);
>>>> 
>>>> return contactDto;
>>>> }
>>>> 
>>>> Is there a way to achieve what I want, keep my rows at language switching
>>>> without persisting in db ?
>>>> 
>>> 
>>> Look at the @Persist annotation. Session persistence. Again, it's
>>> completely unrelated to language switching.
>>> 
>>> @Persist
>>> private ContactDto contactDto;
>>> 
>>> 
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Tapestry, Java and Hibernate consultant and developer
>>> http://machina.com.br
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
I added @Persist on a field in my form, it doesn't persist if switch
locale. But if I try to submit (onSubmit not implemented in the .java) then
the field become really persistente, even if I switch locale  the field
stay filled.
Why this behavior ? How can I get this persistency between locale switching
without having to "fail-submit" before ?


2014-07-17 10:23 GMT+02:00 squallmat . <sq...@gmail.com>:

> I added @Persist on both source and value, now fields persist between
> languages.
> But localization switching reload the page, so I assume if I want the
> field that were filled to stay filled at language switching I need to put
> on all my Property with @Persist and refill each field in SetupRender,
> right ?
>
> Is this possible to have localization switchin without page reloading, and
> only the labels "ajaxly" updated ?
>
>
> 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <
> thiagohp@gmail.com>:
>
> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
>> wrote:
>>
>>  Still, in the Client entity that i will persist at the submit, I store my
>>> contacts in it :
>>> // when adding a contact row
>>> Object onAddRowFromContacts() {
>>> ContactDto contactDto = new ContactDto();
>>>
>>> clientDto.getContactList().add(contactDto);
>>>
>>> return contactDto;
>>> }
>>>
>>> Is there a way to achieve what I want, keep my rows at language switching
>>> without persisting in db ?
>>>
>>
>> Look at the @Persist annotation. Session persistence. Again, it's
>> completely unrelated to language switching.
>>
>> @Persist
>> private ContactDto contactDto;
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
I added @Persist on both source and value, now fields persist between
languages.
But localization switching reload the page, so I assume if I want the field
that were filled to stay filled at language switching I need to put on all
my Property with @Persist and refill each field in SetupRender, right ?

Is this possible to have localization switchin without page reloading, and
only the labels "ajaxly" updated ?


2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>
> wrote:
>
>  Still, in the Client entity that i will persist at the submit, I store my
>> contacts in it :
>> // when adding a contact row
>> Object onAddRowFromContacts() {
>> ContactDto contactDto = new ContactDto();
>>
>> clientDto.getContactList().add(contactDto);
>>
>> return contactDto;
>> }
>>
>> Is there a way to achieve what I want, keep my rows at language switching
>> without persisting in db ?
>>
>
> Look at the @Persist annotation. Session persistence. Again, it's
> completely unrelated to language switching.
>
> @Persist
> private ContactDto contactDto;
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: ajaxformloop and localization

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . <sq...@gmail.com>  
wrote:

> Still, in the Client entity that i will persist at the submit, I store my
> contacts in it :
> // when adding a contact row
> Object onAddRowFromContacts() {
> ContactDto contactDto = new ContactDto();
>
> clientDto.getContactList().add(contactDto);
>
> return contactDto;
> }
>
> Is there a way to achieve what I want, keep my rows at language switching
> without persisting in db ?

Look at the @Persist annotation. Session persistence. Again, it's  
completely unrelated to language switching.

@Persist
private ContactDto contactDto;

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ajaxformloop and localization

Posted by "squallmat ." <sq...@gmail.com>.
I'm trying to create an entity Client which has a list of Contacts,
In my persistence layer these Contacts are stored by cascading on the
storing of a client, then I don't want to persist my contact in my db one
by one when I add a row.

Still, in the Client entity that i will persist at the submit, I store my
contacts in it :
// when adding a contact row
Object onAddRowFromContacts() {
ContactDto contactDto = new ContactDto();

clientDto.getContactList().add(contactDto);

return contactDto;
}

Is there a way to achieve what I want, keep my rows at language switching
without persisting in db ?



And also, how can I change the the text "Add row" ?


(And yet : thanks for your help)


2014-07-16 17:39 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Wed, 16 Jul 2014 11:05:30 -0300, squallmat . <sq...@gmail.com>
> wrote:
>
>  I'm using an ajaxformloop component, that works really well.
>>
>> But my webapp is developed in two languages : english and french, and when
>> I tried to switch to another localization the added rows disappear,
>> and if i switch back to the first langauge the rows are reappearing and
>> are
>> empty.
>>
>> Is there methods to make ajaxformloop working in case of localization
>> switching ?
>>
>
> This is completely unrelated to language switching. This is caused by your
> code not persisting the data in the form in some way or another. Any other
> action which reloads the page would do the same.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: ajaxformloop and localization

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 16 Jul 2014 11:05:30 -0300, squallmat . <sq...@gmail.com>  
wrote:

> I'm using an ajaxformloop component, that works really well.
>
> But my webapp is developed in two languages : english and french, and  
> when
> I tried to switch to another localization the added rows disappear,
> and if i switch back to the first langauge the rows are reappearing and  
> are
> empty.
>
> Is there methods to make ajaxformloop working in case of localization
> switching ?

This is completely unrelated to language switching. This is caused by your  
code not persisting the data in the form in some way or another. Any other  
action which reloads the page would do the same.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org