Thanks for the advice Igor.
I passed the actual values to the second tab (via the submit method of the
form) just to see if it's working.
So I guess that in the onSubmit method of the form, it's better to pass a
model than an object
public class GererMesLignesUnitForm extends Form {
...
protected void onSubmit() {
Object newObject = createNewObjectFromRequest();
/* Previous call
* GererMesLignesUnitPage pageResultat = new
GererMesLignesUnitPage(1, newObject);
*/
GererMesLignesUnitPage pageResultat = new
GererMesLignesUnitPage(1, newModelFromNewObject);
setResponsePage(pageResultat);
}
}
But that doesn't resolve my problem. How can I keep the input in the form
of the first tab in this case :
- User fill the form on the first tab
- User submit the form on the first tab
- application do the search using the form input and show the result on
the second tab with
- User want to the same search with more criteria so he switch back on the
first tab
- User have to fill back all his criteria ... <=== How can I keep them ?
- Should I pass the model of the form and the model of the result in the
onSubmit() method ?
- If not, do I use correctly the PanelCachingTab in my previous example ?
De :
Igor Vaynberg <[email protected]>
A:
[email protected]
Date:
27/02/2009 18:08
Objet :
Re: [AjaxTabbedPanel] Switching between form and result tab
p.add(new Label("statut", demande.getStatut()));
^ you should use models instead of passing it actual values, that way
your data doesnt get out of sync.
see the models page on the wiki
-igor
2009/2/27 <[email protected]>:
> I've already try that. It didn't work.
> But maybe I'm doing something wrong ...
>
> Here's the page code :
>
>
> private DemandeUnitaire demande;
> private GererMesLignesUnitForm myForm;
> private AjaxTabbedPanel tabPanel;
> private Panel currentPanel;
>
> public GererMesLignesUnitPage(int selectedTab, Object infosToShow) {
>
> if (selectedTab == 1)
> demande = (DemandeUnitaire) infosToShow;
>
> myForm = new GererMesLignesUnitForm("recherche", new
CompoundPropertyModel
> (new DemandeUnitaire()));
> List tabs = new ArrayList();
>
> tabs.add(new PanelCachingTab(
> new AbstractTab(new Model("first tab")) {
> private static final long serialVersionUID = 1L;
> public Panel getPanel(String panelId) {
>
> Panel p = new TabPanel1(panelId);
>
> FeedbackPanel feedback = new FeedbackPanel("msgs"
> );
> p.add(feedback);
>
>
> p.add(myForm);
>
> return p;
> }
> }
> ) {
> @Override
> public Panel getPanel(final String panelId) {
> return super.getPanel(panelId);
> }
> });
>
> tabs.add(new PanelCachingTab(
> new AbstractTab(new Model("second tab")) {
> private static final long serialVersionUID = 1L;
> public Panel getPanel(String panelId) {
>
> Panel p = new TabPanel2(panelId);
> p.add(new Label("statut", demande.getStatut()));
> p.add(new Label("numMachine", demande
> .getNumMachine()));
>
> HeaderContributor alert = new HeaderContributor(
> new IHeaderContributor() {
> public void
> renderHead(IHeaderResponse response) {
> response.renderOnLoadJavascript("onloadEvent();");
> }
> }
> );
>
> p.add(HeaderContributor.forJavaScript( LIB_JS ));
> p.add(HeaderContributor.forJavaScript(
> SHOW_HIDE_COLUMN_JS ));
> p.add(alert);
> return p;
> }
> }
> ) {
> @Override
> public Panel getPanel(final String panelId) {
> return super.getPanel(panelId);
> }
> });
>
>
>
>
>
>
> De :
> Igor Vaynberg <[email protected]>
> A:
> [email protected]
> Date:
> 27/02/2009 17:27
> Objet :
> Re: [AjaxTabbedPanel] Switching between form and result tab
>
>
>
> use panelcachingtab instead of abstracttab
>
> -igor
>
> 2009/2/27 <[email protected]>:
>> Hi,
>>
>> Anyone have an idea on the matter below ?
>>
>> Cheers,
>>
>> Val
>>
>>
>>
>> De :
>> [email protected]
>> A:
>> [email protected]
>> Date:
>> 26/02/2009 14:11
>> Objet :
>> [AjaxTabbedPanel] Switching between form and result tab
>>
>>
>>
>> Hi,
>>
>> I have an AjacTabbedPanel with two tabs.
>> The first tab is a form which, when submitted, show the result on the
>> second tabs.
>> So far, everything's fine.
>>
>> I want to keep the input from the form after the submit so that the
user
>> can come back to the first tab and have a look at what the crierias was
>> and maybe to modify them to make another request.
>> But I need to be able switch back to the second tab and keep records of
>> the result if the user didn't resubmit the form.
>>
>> I've search through the mailing list and the solution that come up most
>> often is to override newLink to return an ajaxSubmitLink. But I don't
>> think that's the solution for me since the form is only on the first
>> panel.
>>
>> Cheers,
>>
>> Valery
>>
>>
>>
>>
Ce message est à l'attention exclusive des destinataires désignés. Il peut
contenir des informations confidentielles. Si vous n'êtes pas destinataire
du message, merci d'en avertir immédiatement l'expéditeur et de détruire
ce message. Le contenu de ce message ne pourrait engager la responsabilité
de Steria que s'il a été émis par une personne dûment habilitée agissant
dans le strict cadre de ses fonctions et à des fins non étrangères à ses
attributions. Bien que les meilleurs efforts soient faits pour maintenir
cette transmission exempte de tout virus, l'expéditeur ne donne aucune
garantie à cet égard et sa responsabilité ne saurait être engagée pour
tout dommage résultant d'un virus transmis.
This message is intended exclusively for the designated addressee. It may
contain confidential material. If you are not the correct addressee,
please notify the sender immediately and destroy the message. The content
of this message will engage the responsibility of Steria only if it has
been sent by an authorized person acting in the strict scope of his
functions and for purposes that are related to his competence. Although
reasonable efforts have been made to keep this transmission free from
viruses, the sender will not be liable for damages caused by a transmitted
virus.