You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pieter claassen <pi...@gmail.com> on 2009/11/10 08:19:17 UTC

Force page reload/re-render

I have a link on a panel that is included in many pages. When the user
clicks on the link, I change something in the user settings that will
affect what gets displayed on the page. However, for that to work, I
need to reload the page after the user clicked on the link as by
default the other components that now need to be checked for
conditional visibility don't re-render (why not?). setResponsePage()
requires me to pass into the panel a target page and this becomes
complex when you have a mix of statefull and stateless pages as
targets (and it just doesn't feel right).

I am sure there must be an easier way to just re-render a page?

Any tips?

Thanks,
pieter

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


Re: Force page reload/re-render

Posted by Matthias Keller <ma...@ergon.ch>.
Hi Pieter

Due to the Java-Nature of Wicket, things done in the constructor are 
only executed once for this instance. Since F5 only re-renders the 
instance, the expression   setVisible(whatever())  is only executed once.
The most dynamic implementation would be to override  isVisible()  for 
every component that changes its visibility dynamically or if that would 
lead to lots of code duplication, you could write a behaviour doing 
exactly that and add it to every component (or container) as needed.
isVisible()  is evaluated during each and every rendering phase, meaning 
upon every F5 reload as well.

This is the way we do it for dynamic content.

Matt

pieter claassen wrote:
> Hi Ernesto,
>
> To recap, I have a control panel visible on each and every page and in
> that control panel, you can select the appropriate role you want to
> use. Based on that role some menu items will be visible or not
> (example below is correct). I am sure this problem has been solved
> before :-0 as this is a very normal usecase for context sensitive
> navigation.
>
> It seems that there is no way to force the page to re-render using getPage()?
>
> Thanks for the feedback so far. I keep on coming up against this issue
> and have not found a reasonable solution to the problem. The
> javascript option seems to be best so far.
>
> Pieter
>
> On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
> <re...@gmail.com> wrote:
>   
>> Even if you re-render your page components that are not "dynamic" will not
>> change their state: unless you create a new instance of the page, I guess.
>> By this I mean.
>>
>> class MyPanel .... {
>>       public MyPanel(id) {
>>           PanelB panelB = new Panel("B");
>>           panelB.setVisible(getSomeCondition());
>>           ....
>>       }
>> }
>>
>> Even if condition getSomeCondition() change, and you re-render  MyPanel, or
>> the whole page, panelB will still be not visible. So, if you want something
>> to be dynamic you have to program it to be dynamic.
>>
>> Best,
>>
>> Ernesto
>>
>>
>> On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen <pi...@gmail.com>
>> wrote:
>>     
>>> Both of the suggestions I think requires me to modify the logic of the
>>> controls (either to keep track of which ones need to be updated or by
>>> placing the rendering logic in onBeforeRender()). I think this is a
>>> lot of work for something relative straight forward and also any
>>> changes to permission structures and I have to modify controls.
>>>
>>> Is there no way that I can mark a page obtained via getPage() as
>>> requiring re-rendering? I tried getPage().dirty() before the
>>> setResponsePage() but that didn't do anything.
>>>
>>> Thanks for the feedback though.
>>> P
>>>
>>> On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos <pe...@gmail.com> wrote:
>>>       
>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>> re-render controls on the page.
>>>>
>>>> Where do you implement your control ( update logic )? Consider do it
>>>> overriding Component.onBeforeRender method
>>>>
>>>> On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
>>>> <pi...@gmail.com> wrote:
>>>>         
>>>>> Hi Pedro,
>>>>>
>>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>>> re-render controls on the page.
>>>>>
>>>>> setResponsePage(getPage().getClass()) only works for stateless pages
>>>>> and on most of my pages, I pass params via the constructor.
>>>>>
>>>>> The javascript option will be a last resort, but it seems to be not
>>>>> the most elegant solution.
>>>>>
>>>>> Rgds,
>>>>>
>>>>> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com>
>>>>> wrote:
>>>>>           
>>>>>> if(userSetWasChanged){
>>>>>> target.appendJavascript("window.location.reload()");
>>>>>> or
>>>>>> setResponsePage(getPage());
>>>>>> or
>>>>>> setResponsePage(getPage().getClass());
>>>>>> }
>>>>>>
>>>>>>
>>>>>> On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>>>>>> <pi...@gmail.com>
>>>>>> wrote:
>>>>>>             
>>>>>>> I have a link on a panel that is included in many pages. When the
>>>>>>> user
>>>>>>> clicks on the link, I change something in the user settings that
>>>>>>> will
>>>>>>> affect what gets displayed on the page. However, for that to work, I
>>>>>>> need to reload the page after the user clicked on the link as by
>>>>>>> default the other components that now need to be checked for
>>>>>>> conditional visibility don't re-render (why not?). setResponsePage()
>>>>>>> requires me to pass into the panel a target page and this becomes
>>>>>>> complex when you have a mix of statefull and stateless pages as
>>>>>>> targets (and it just doesn't feel right).
>>>>>>>
>>>>>>> I am sure there must be an easier way to just re-render a page?
>>>>>>>
>>>>>>> Any tips?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> pieter
>>>>>>>               


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
Yes. Looks like this is the only non-JS way to go (still searching).
Simple but ugly.

Regards,
Stephan

Am 11.11.2009 um 21:53 schrieb Igor Vaynberg:

> you should do something like this
> 
> [form1][select/][submit button/][/form1]
> [form2][form components panel/][/form2]
> 
> user presses the submit button in form 1, in form 1's onsubmit you
> swap the form components panel based on the selection.
> 
> simple.
> 
> -igor
> 
> On Wed, Nov 11, 2009 at 12:50 PM, srm <sr...@schokokeks.org> wrote:
>> Ah! Stupid me!
>> I've read that it is working with JS and I didn't make sure to disable JS for
>> my local host.
>> Aaaaargh.
>> 
>> So it's not solved. Need to find a way around then.
>> 
>> Thanks for the pointer.
>> 
>> Regards,
>> Stephan
>> 
>> Am 11.11.2009 um 21:44 schrieb Martijn Dashorst:
>> 
>>> How do you think wantOnSelectionChangedNotification() works? With or without JS?
>>> 
>>> Martijn
>>> 
>>> On Wed, Nov 11, 2009 at 9:39 PM, srm <sr...@schokokeks.org> wrote:
>>>> SOLVED!
>>>> w/o JS/AJAX
>>>> 
>>>> I created a factory to produce the corresponding Panel(including the form)
>>>> and I use a call to replaceWith() in onSelectionChanged():
>>>> 
>>>> [code]
>>>>  @Override
>>>>   protected void onSelectionChanged(final Object newSelection) {
>>>>    Panel newPanel = AddItemPanel.getAddItemPanel(selected, "addArticlePanel"); //the factory call
>>>>    addArticlePanel.replaceWith(newPanel);
>>>>    addArticlePanel = newPanel;
>>>>   }
>>>> 
>>>> Thanks to martin-g @ #wicket.
>>>> 
>>>> Regards,
>>>> Stephan
>>>> 
>>>> Am 11.11.2009 um 16:18 schrieb srm:
>>>> 
>>>>> Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:
>>>>> 
>>>>>> If you reload the page when selecting the element, instead of using AJAX, I
>>>>>> guess the same will work because you have a selected article... I think AJAX
>>>>>> is just a detail here, maybe you can use
>>>>>> 
>>>>>> protected boolean wantOnSelectionChangedNotifications()
>>>>>>   {
>>>>>>       return false;
>>>>>>   }
>>>>>> 
>>>>>> on DropDownChoice?
>>>>>> 
>>>>> 
>>>>> 
>>>>> From my understanding, I need wantOnSelectionChangedNotifications()
>>>>> returning TRUE, otherwise onSelectionChanged() is never triggered.
>>>>> My current approach as follows. That's working but it doesn't feel right.
>>>>> To clumsy. Any ideas? (and I beg your pardon for mixing german
>>>>> with english in the code ;) )
>>>>> 
>>>>> package view;
>>>>> 
>>>>> ..some imports...
>>>>> public class AddArticlePage extends StorePage {
>>>>> 
>>>>>  private AddArticlePanel addArticlePanel;
>>>>> 
>>>>>  @SuppressWarnings("unchecked")
>>>>>  public AddArticlePage() {
>>>>>   addArticlePanel = new AddArticlePanel("addArticlePanel");
>>>>>   addArticlePanel.setVisible(false);
>>>>>   DropDownChoice dropDownType = new DropDownChoice("dropDownType",
>>>>>     new PropertyModel(this, "selected"), Artikel.TYPELIST) {
>>>>>    protected boolean wantOnSelectionChangedNotifications() {
>>>>>                return true;
>>>>>            }
>>>>>    @Override
>>>>>    protected void onSelectionChanged(final Object newSelection) {
>>>>>     System.out.println("SELECTION CHANGED!");
>>>>>     System.out.println("new Selection = " + (String) newSelection);
>>>>>     addArticlePanel.setVisibleFields((String) newSelection);
>>>>>     addArticlePanel.setVisible(true);
>>>>>    }
>>>>>   };
>>>>> 
>>>>>   Form formAdd = new Form("addArticleForm") {
>>>>>    @Override
>>>>>    protected void onSubmit() {
>>>>>     System.out.println("Added Article...");
>>>>>    }
>>>>>   };
>>>>> 
>>>>>   add(dropDownType);
>>>>>   add(addArticlePanel);
>>>>>   add(formAdd);
>>>>> 
>>>>>  }
>>>>> }
>>>>> 
>>>>> 
>>>>> /***** THE PANEL CLASS ******/
>>>>> public class AddArticlePanel extends Panel {
>>>>> 
>>>>>  private TextField artikelNummer;
>>>>>  private TextField preis;
>>>>>  private TextField erscheinungsJahr;
>>>>>  private TextField beschreibung;
>>>>>  private TextField titel;
>>>>> 
>>>>>  //fields for BOOK
>>>>>  private TextField isbn;
>>>>>  private TextField autor;
>>>>>  private TextField verlag;
>>>>> 
>>>>>  //fields for CD
>>>>>  private TextField label;
>>>>>  private TextField artist;
>>>>> 
>>>>>  public AddArticlePanel(String id) {
>>>>>   super(id);
>>>>> 
>>>>>   artikelNummer = new TextField("artikelNummer", new Model());
>>>>>   preis = new TextField("preis", new Model());
>>>>>   erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
>>>>>   beschreibung = new TextField("beschreibung", new Model());
>>>>>   titel = new TextField("titel", new Model());
>>>>>   isbn = new TextField("isbn", new Model());
>>>>>   autor = new TextField("autor", new Model());
>>>>>   verlag = new TextField("verlag", new Model());
>>>>>   label = new TextField("label", new Model());
>>>>>   artist = new TextField("artist", new Model());
>>>>>   add(artikelNummer);
>>>>>   add(preis);
>>>>>   add(erscheinungsJahr);
>>>>>   add(beschreibung);
>>>>>   add(titel);
>>>>>   add(isbn);
>>>>>   add(autor);
>>>>>   add(verlag);
>>>>>   add(label);
>>>>>   add(artist);
>>>>> 
>>>>> // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
>>>>> // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
>>>>> // SOUNDS AWFULL!
>>>>> 
>>>>>  }
>>>>> 
>>>>>        //could probably be optimised
>>>>>  public void setVisibleFields(String type) {
>>>>>   if (type.equals("BOOK")) {
>>>>>    isbn.setVisible(true);
>>>>>    autor.setVisible(true);
>>>>>    verlag.setVisible(true);
>>>>> 
>>>>>    label.setVisible(false);
>>>>>    artist.setVisible(false);
>>>>>   }
>>>>>   else {
>>>>>    isbn.setVisible(false);
>>>>>    autor.setVisible(false);
>>>>>    verlag.setVisible(false);
>>>>> 
>>>>>    label.setVisible(true);
>>>>>    artist.setVisible(true);
>>>>>   }
>>>>>  }
>>>>> 
>>>>> 
>>>>> }
>>>>> 
>>>>> Comments please :)
>>>>> 
>>>>> 
>>>>>> Best,
>>>>>> 
>>>>>> Ernesto
>>>>>> 
>>>>>> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
>>>>>> 
>>>>>>> 
>>>>>>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>>>>>>> 
>>>>>>>> I have used something similar to
>>>>>>> [snip]
>>>>>>> [snap]
>>>>>>>> 
>>>>>>>> for such situations... I delegate creation to a factory class (so that
>>>>>>> new
>>>>>>>> products can be plugged in).
>>>>>>>> 
>>>>>>>> Best,
>>>>>>>> 
>>>>>>>> Ernesto
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> Thank you for this example.
>>>>>>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Stephan
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>>>>>>> 
>>>>>>>>> How would you approach the following:
>>>>>>>>> PageA is used to insert an article. At first, the user chooses what kind
>>>>>>> of
>>>>>>>>> article to insert (DropDownChoice).
>>>>>>>>> When the User made his choice, a coresponding form should be
>>>>>>> loaded/visible
>>>>>>>>> underneath the
>>>>>>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>>>>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>>>>>>> holds
>>>>>>>>> all fields for any kind of article
>>>>>>>>> and make them visible depending on what the user has chosen (using
>>>>>>>>> onSelectionChanged).
>>>>>>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>>>>>>> this.
>>>>>>>>> 
>>>>>>>>> Further information will be happily provided.
>>>>>>>>> 
>>>>>>>>> Regards,
>>>>>>>>> Stephan
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>> 
>>>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>>> Apache Wicket 1.4 increases type safety for web applications
>>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by Igor Vaynberg <ig...@gmail.com>.
you should do something like this

[form1][select/][submit button/][/form1]
[form2][form components panel/][/form2]

user presses the submit button in form 1, in form 1's onsubmit you
swap the form components panel based on the selection.

simple.

-igor

On Wed, Nov 11, 2009 at 12:50 PM, srm <sr...@schokokeks.org> wrote:
> Ah! Stupid me!
> I've read that it is working with JS and I didn't make sure to disable JS for
> my local host.
> Aaaaargh.
>
> So it's not solved. Need to find a way around then.
>
> Thanks for the pointer.
>
> Regards,
> Stephan
>
> Am 11.11.2009 um 21:44 schrieb Martijn Dashorst:
>
>> How do you think wantOnSelectionChangedNotification() works? With or without JS?
>>
>> Martijn
>>
>> On Wed, Nov 11, 2009 at 9:39 PM, srm <sr...@schokokeks.org> wrote:
>>> SOLVED!
>>> w/o JS/AJAX
>>>
>>> I created a factory to produce the corresponding Panel(including the form)
>>> and I use a call to replaceWith() in onSelectionChanged():
>>>
>>> [code]
>>>  @Override
>>>   protected void onSelectionChanged(final Object newSelection) {
>>>    Panel newPanel = AddItemPanel.getAddItemPanel(selected, "addArticlePanel"); //the factory call
>>>    addArticlePanel.replaceWith(newPanel);
>>>    addArticlePanel = newPanel;
>>>   }
>>>
>>> Thanks to martin-g @ #wicket.
>>>
>>> Regards,
>>> Stephan
>>>
>>> Am 11.11.2009 um 16:18 schrieb srm:
>>>
>>>> Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:
>>>>
>>>>> If you reload the page when selecting the element, instead of using AJAX, I
>>>>> guess the same will work because you have a selected article... I think AJAX
>>>>> is just a detail here, maybe you can use
>>>>>
>>>>> protected boolean wantOnSelectionChangedNotifications()
>>>>>   {
>>>>>       return false;
>>>>>   }
>>>>>
>>>>> on DropDownChoice?
>>>>>
>>>>
>>>>
>>>> From my understanding, I need wantOnSelectionChangedNotifications()
>>>> returning TRUE, otherwise onSelectionChanged() is never triggered.
>>>> My current approach as follows. That's working but it doesn't feel right.
>>>> To clumsy. Any ideas? (and I beg your pardon for mixing german
>>>> with english in the code ;) )
>>>>
>>>> package view;
>>>>
>>>> ..some imports...
>>>> public class AddArticlePage extends StorePage {
>>>>
>>>>  private AddArticlePanel addArticlePanel;
>>>>
>>>>  @SuppressWarnings("unchecked")
>>>>  public AddArticlePage() {
>>>>   addArticlePanel = new AddArticlePanel("addArticlePanel");
>>>>   addArticlePanel.setVisible(false);
>>>>   DropDownChoice dropDownType = new DropDownChoice("dropDownType",
>>>>     new PropertyModel(this, "selected"), Artikel.TYPELIST) {
>>>>    protected boolean wantOnSelectionChangedNotifications() {
>>>>                return true;
>>>>            }
>>>>    @Override
>>>>    protected void onSelectionChanged(final Object newSelection) {
>>>>     System.out.println("SELECTION CHANGED!");
>>>>     System.out.println("new Selection = " + (String) newSelection);
>>>>     addArticlePanel.setVisibleFields((String) newSelection);
>>>>     addArticlePanel.setVisible(true);
>>>>    }
>>>>   };
>>>>
>>>>   Form formAdd = new Form("addArticleForm") {
>>>>    @Override
>>>>    protected void onSubmit() {
>>>>     System.out.println("Added Article...");
>>>>    }
>>>>   };
>>>>
>>>>   add(dropDownType);
>>>>   add(addArticlePanel);
>>>>   add(formAdd);
>>>>
>>>>  }
>>>> }
>>>>
>>>>
>>>> /***** THE PANEL CLASS ******/
>>>> public class AddArticlePanel extends Panel {
>>>>
>>>>  private TextField artikelNummer;
>>>>  private TextField preis;
>>>>  private TextField erscheinungsJahr;
>>>>  private TextField beschreibung;
>>>>  private TextField titel;
>>>>
>>>>  //fields for BOOK
>>>>  private TextField isbn;
>>>>  private TextField autor;
>>>>  private TextField verlag;
>>>>
>>>>  //fields for CD
>>>>  private TextField label;
>>>>  private TextField artist;
>>>>
>>>>  public AddArticlePanel(String id) {
>>>>   super(id);
>>>>
>>>>   artikelNummer = new TextField("artikelNummer", new Model());
>>>>   preis = new TextField("preis", new Model());
>>>>   erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
>>>>   beschreibung = new TextField("beschreibung", new Model());
>>>>   titel = new TextField("titel", new Model());
>>>>   isbn = new TextField("isbn", new Model());
>>>>   autor = new TextField("autor", new Model());
>>>>   verlag = new TextField("verlag", new Model());
>>>>   label = new TextField("label", new Model());
>>>>   artist = new TextField("artist", new Model());
>>>>   add(artikelNummer);
>>>>   add(preis);
>>>>   add(erscheinungsJahr);
>>>>   add(beschreibung);
>>>>   add(titel);
>>>>   add(isbn);
>>>>   add(autor);
>>>>   add(verlag);
>>>>   add(label);
>>>>   add(artist);
>>>>
>>>> // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
>>>> // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
>>>> // SOUNDS AWFULL!
>>>>
>>>>  }
>>>>
>>>>        //could probably be optimised
>>>>  public void setVisibleFields(String type) {
>>>>   if (type.equals("BOOK")) {
>>>>    isbn.setVisible(true);
>>>>    autor.setVisible(true);
>>>>    verlag.setVisible(true);
>>>>
>>>>    label.setVisible(false);
>>>>    artist.setVisible(false);
>>>>   }
>>>>   else {
>>>>    isbn.setVisible(false);
>>>>    autor.setVisible(false);
>>>>    verlag.setVisible(false);
>>>>
>>>>    label.setVisible(true);
>>>>    artist.setVisible(true);
>>>>   }
>>>>  }
>>>>
>>>>
>>>> }
>>>>
>>>> Comments please :)
>>>>
>>>>
>>>>> Best,
>>>>>
>>>>> Ernesto
>>>>>
>>>>> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
>>>>>
>>>>>>
>>>>>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>>>>>>
>>>>>>> I have used something similar to
>>>>>> [snip]
>>>>>> [snap]
>>>>>>>
>>>>>>> for such situations... I delegate creation to a factory class (so that
>>>>>> new
>>>>>>> products can be plugged in).
>>>>>>>
>>>>>>> Best,
>>>>>>>
>>>>>>> Ernesto
>>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you for this example.
>>>>>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>>>>>>
>>>>>> Regards,
>>>>>> Stephan
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>>>>>>
>>>>>>>> How would you approach the following:
>>>>>>>> PageA is used to insert an article. At first, the user chooses what kind
>>>>>> of
>>>>>>>> article to insert (DropDownChoice).
>>>>>>>> When the User made his choice, a coresponding form should be
>>>>>> loaded/visible
>>>>>>>> underneath the
>>>>>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>>>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>>>>>> holds
>>>>>>>> all fields for any kind of article
>>>>>>>> and make them visible depending on what the user has chosen (using
>>>>>>>> onSelectionChanged).
>>>>>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>>>>>> this.
>>>>>>>>
>>>>>>>> Further information will be happily provided.
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Stephan
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.4 increases type safety for web applications
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
Ah! Stupid me!
I've read that it is working with JS and I didn't make sure to disable JS for
my local host.
Aaaaargh.

So it's not solved. Need to find a way around then.

Thanks for the pointer.

Regards,
Stephan

Am 11.11.2009 um 21:44 schrieb Martijn Dashorst:

> How do you think wantOnSelectionChangedNotification() works? With or without JS?
> 
> Martijn
> 
> On Wed, Nov 11, 2009 at 9:39 PM, srm <sr...@schokokeks.org> wrote:
>> SOLVED!
>> w/o JS/AJAX
>> 
>> I created a factory to produce the corresponding Panel(including the form)
>> and I use a call to replaceWith() in onSelectionChanged():
>> 
>> [code]
>>  @Override
>>   protected void onSelectionChanged(final Object newSelection) {
>>    Panel newPanel = AddItemPanel.getAddItemPanel(selected, "addArticlePanel"); //the factory call
>>    addArticlePanel.replaceWith(newPanel);
>>    addArticlePanel = newPanel;
>>   }
>> 
>> Thanks to martin-g @ #wicket.
>> 
>> Regards,
>> Stephan
>> 
>> Am 11.11.2009 um 16:18 schrieb srm:
>> 
>>> Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:
>>> 
>>>> If you reload the page when selecting the element, instead of using AJAX, I
>>>> guess the same will work because you have a selected article... I think AJAX
>>>> is just a detail here, maybe you can use
>>>> 
>>>> protected boolean wantOnSelectionChangedNotifications()
>>>>   {
>>>>       return false;
>>>>   }
>>>> 
>>>> on DropDownChoice?
>>>> 
>>> 
>>> 
>>> From my understanding, I need wantOnSelectionChangedNotifications()
>>> returning TRUE, otherwise onSelectionChanged() is never triggered.
>>> My current approach as follows. That's working but it doesn't feel right.
>>> To clumsy. Any ideas? (and I beg your pardon for mixing german
>>> with english in the code ;) )
>>> 
>>> package view;
>>> 
>>> ..some imports...
>>> public class AddArticlePage extends StorePage {
>>> 
>>>  private AddArticlePanel addArticlePanel;
>>> 
>>>  @SuppressWarnings("unchecked")
>>>  public AddArticlePage() {
>>>   addArticlePanel = new AddArticlePanel("addArticlePanel");
>>>   addArticlePanel.setVisible(false);
>>>   DropDownChoice dropDownType = new DropDownChoice("dropDownType",
>>>     new PropertyModel(this, "selected"), Artikel.TYPELIST) {
>>>    protected boolean wantOnSelectionChangedNotifications() {
>>>                return true;
>>>            }
>>>    @Override
>>>    protected void onSelectionChanged(final Object newSelection) {
>>>     System.out.println("SELECTION CHANGED!");
>>>     System.out.println("new Selection = " + (String) newSelection);
>>>     addArticlePanel.setVisibleFields((String) newSelection);
>>>     addArticlePanel.setVisible(true);
>>>    }
>>>   };
>>> 
>>>   Form formAdd = new Form("addArticleForm") {
>>>    @Override
>>>    protected void onSubmit() {
>>>     System.out.println("Added Article...");
>>>    }
>>>   };
>>> 
>>>   add(dropDownType);
>>>   add(addArticlePanel);
>>>   add(formAdd);
>>> 
>>>  }
>>> }
>>> 
>>> 
>>> /***** THE PANEL CLASS ******/
>>> public class AddArticlePanel extends Panel {
>>> 
>>>  private TextField artikelNummer;
>>>  private TextField preis;
>>>  private TextField erscheinungsJahr;
>>>  private TextField beschreibung;
>>>  private TextField titel;
>>> 
>>>  //fields for BOOK
>>>  private TextField isbn;
>>>  private TextField autor;
>>>  private TextField verlag;
>>> 
>>>  //fields for CD
>>>  private TextField label;
>>>  private TextField artist;
>>> 
>>>  public AddArticlePanel(String id) {
>>>   super(id);
>>> 
>>>   artikelNummer = new TextField("artikelNummer", new Model());
>>>   preis = new TextField("preis", new Model());
>>>   erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
>>>   beschreibung = new TextField("beschreibung", new Model());
>>>   titel = new TextField("titel", new Model());
>>>   isbn = new TextField("isbn", new Model());
>>>   autor = new TextField("autor", new Model());
>>>   verlag = new TextField("verlag", new Model());
>>>   label = new TextField("label", new Model());
>>>   artist = new TextField("artist", new Model());
>>>   add(artikelNummer);
>>>   add(preis);
>>>   add(erscheinungsJahr);
>>>   add(beschreibung);
>>>   add(titel);
>>>   add(isbn);
>>>   add(autor);
>>>   add(verlag);
>>>   add(label);
>>>   add(artist);
>>> 
>>> // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
>>> // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
>>> // SOUNDS AWFULL!
>>> 
>>>  }
>>> 
>>>        //could probably be optimised
>>>  public void setVisibleFields(String type) {
>>>   if (type.equals("BOOK")) {
>>>    isbn.setVisible(true);
>>>    autor.setVisible(true);
>>>    verlag.setVisible(true);
>>> 
>>>    label.setVisible(false);
>>>    artist.setVisible(false);
>>>   }
>>>   else {
>>>    isbn.setVisible(false);
>>>    autor.setVisible(false);
>>>    verlag.setVisible(false);
>>> 
>>>    label.setVisible(true);
>>>    artist.setVisible(true);
>>>   }
>>>  }
>>> 
>>> 
>>> }
>>> 
>>> Comments please :)
>>> 
>>> 
>>>> Best,
>>>> 
>>>> Ernesto
>>>> 
>>>> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
>>>> 
>>>>> 
>>>>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>>>>> 
>>>>>> I have used something similar to
>>>>> [snip]
>>>>> [snap]
>>>>>> 
>>>>>> for such situations... I delegate creation to a factory class (so that
>>>>> new
>>>>>> products can be plugged in).
>>>>>> 
>>>>>> Best,
>>>>>> 
>>>>>> Ernesto
>>>>>> 
>>>>> 
>>>>> 
>>>>> Thank you for this example.
>>>>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>>>>> 
>>>>> Regards,
>>>>> Stephan
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>>>>> 
>>>>>>> How would you approach the following:
>>>>>>> PageA is used to insert an article. At first, the user chooses what kind
>>>>> of
>>>>>>> article to insert (DropDownChoice).
>>>>>>> When the User made his choice, a coresponding form should be
>>>>> loaded/visible
>>>>>>> underneath the
>>>>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>>>>> holds
>>>>>>> all fields for any kind of article
>>>>>>> and make them visible depending on what the user has chosen (using
>>>>>>> onSelectionChanged).
>>>>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>>>>> this.
>>>>>>> 
>>>>>>> Further information will be happily provided.
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Stephan
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>> 
>>>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
> 
> 
> 
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.4 increases type safety for web applications
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by Martijn Dashorst <ma...@gmail.com>.
How do you think wantOnSelectionChangedNotification() works? With or without JS?

Martijn

On Wed, Nov 11, 2009 at 9:39 PM, srm <sr...@schokokeks.org> wrote:
> SOLVED!
> w/o JS/AJAX
>
> I created a factory to produce the corresponding Panel(including the form)
> and I use a call to replaceWith() in onSelectionChanged():
>
> [code]
>  @Override
>   protected void onSelectionChanged(final Object newSelection) {
>    Panel newPanel = AddItemPanel.getAddItemPanel(selected, "addArticlePanel"); //the factory call
>    addArticlePanel.replaceWith(newPanel);
>    addArticlePanel = newPanel;
>   }
>
> Thanks to martin-g @ #wicket.
>
> Regards,
> Stephan
>
> Am 11.11.2009 um 16:18 schrieb srm:
>
>> Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:
>>
>>> If you reload the page when selecting the element, instead of using AJAX, I
>>> guess the same will work because you have a selected article... I think AJAX
>>> is just a detail here, maybe you can use
>>>
>>> protected boolean wantOnSelectionChangedNotifications()
>>>   {
>>>       return false;
>>>   }
>>>
>>> on DropDownChoice?
>>>
>>
>>
>> From my understanding, I need wantOnSelectionChangedNotifications()
>> returning TRUE, otherwise onSelectionChanged() is never triggered.
>> My current approach as follows. That's working but it doesn't feel right.
>> To clumsy. Any ideas? (and I beg your pardon for mixing german
>> with english in the code ;) )
>>
>> package view;
>>
>> ..some imports...
>> public class AddArticlePage extends StorePage {
>>
>>  private AddArticlePanel addArticlePanel;
>>
>>  @SuppressWarnings("unchecked")
>>  public AddArticlePage() {
>>   addArticlePanel = new AddArticlePanel("addArticlePanel");
>>   addArticlePanel.setVisible(false);
>>   DropDownChoice dropDownType = new DropDownChoice("dropDownType",
>>     new PropertyModel(this, "selected"), Artikel.TYPELIST) {
>>    protected boolean wantOnSelectionChangedNotifications() {
>>                return true;
>>            }
>>    @Override
>>    protected void onSelectionChanged(final Object newSelection) {
>>     System.out.println("SELECTION CHANGED!");
>>     System.out.println("new Selection = " + (String) newSelection);
>>     addArticlePanel.setVisibleFields((String) newSelection);
>>     addArticlePanel.setVisible(true);
>>    }
>>   };
>>
>>   Form formAdd = new Form("addArticleForm") {
>>    @Override
>>    protected void onSubmit() {
>>     System.out.println("Added Article...");
>>    }
>>   };
>>
>>   add(dropDownType);
>>   add(addArticlePanel);
>>   add(formAdd);
>>
>>  }
>> }
>>
>>
>> /***** THE PANEL CLASS ******/
>> public class AddArticlePanel extends Panel {
>>
>>  private TextField artikelNummer;
>>  private TextField preis;
>>  private TextField erscheinungsJahr;
>>  private TextField beschreibung;
>>  private TextField titel;
>>
>>  //fields for BOOK
>>  private TextField isbn;
>>  private TextField autor;
>>  private TextField verlag;
>>
>>  //fields for CD
>>  private TextField label;
>>  private TextField artist;
>>
>>  public AddArticlePanel(String id) {
>>   super(id);
>>
>>   artikelNummer = new TextField("artikelNummer", new Model());
>>   preis = new TextField("preis", new Model());
>>   erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
>>   beschreibung = new TextField("beschreibung", new Model());
>>   titel = new TextField("titel", new Model());
>>   isbn = new TextField("isbn", new Model());
>>   autor = new TextField("autor", new Model());
>>   verlag = new TextField("verlag", new Model());
>>   label = new TextField("label", new Model());
>>   artist = new TextField("artist", new Model());
>>   add(artikelNummer);
>>   add(preis);
>>   add(erscheinungsJahr);
>>   add(beschreibung);
>>   add(titel);
>>   add(isbn);
>>   add(autor);
>>   add(verlag);
>>   add(label);
>>   add(artist);
>>
>> // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
>> // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
>> // SOUNDS AWFULL!
>>
>>  }
>>
>>        //could probably be optimised
>>  public void setVisibleFields(String type) {
>>   if (type.equals("BOOK")) {
>>    isbn.setVisible(true);
>>    autor.setVisible(true);
>>    verlag.setVisible(true);
>>
>>    label.setVisible(false);
>>    artist.setVisible(false);
>>   }
>>   else {
>>    isbn.setVisible(false);
>>    autor.setVisible(false);
>>    verlag.setVisible(false);
>>
>>    label.setVisible(true);
>>    artist.setVisible(true);
>>   }
>>  }
>>
>>
>> }
>>
>> Comments please :)
>>
>>
>>> Best,
>>>
>>> Ernesto
>>>
>>> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
>>>
>>>>
>>>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>>>>
>>>>> I have used something similar to
>>>> [snip]
>>>> [snap]
>>>>>
>>>>> for such situations... I delegate creation to a factory class (so that
>>>> new
>>>>> products can be plugged in).
>>>>>
>>>>> Best,
>>>>>
>>>>> Ernesto
>>>>>
>>>>
>>>>
>>>> Thank you for this example.
>>>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>>>>
>>>> Regards,
>>>> Stephan
>>>>
>>>>
>>>>
>>>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>>>>
>>>>>> How would you approach the following:
>>>>>> PageA is used to insert an article. At first, the user chooses what kind
>>>> of
>>>>>> article to insert (DropDownChoice).
>>>>>> When the User made his choice, a coresponding form should be
>>>> loaded/visible
>>>>>> underneath the
>>>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>>>> holds
>>>>>> all fields for any kind of article
>>>>>> and make them visible depending on what the user has chosen (using
>>>>>> onSelectionChanged).
>>>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>>>> this.
>>>>>>
>>>>>> Further information will be happily provided.
>>>>>>
>>>>>> Regards,
>>>>>> Stephan
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0

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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
SOLVED!
w/o JS/AJAX

I created a factory to produce the corresponding Panel(including the form)
and I use a call to replaceWith() in onSelectionChanged():

[code]
 @Override
   protected void onSelectionChanged(final Object newSelection) {
    Panel newPanel = AddItemPanel.getAddItemPanel(selected, "addArticlePanel"); //the factory call
    addArticlePanel.replaceWith(newPanel);
    addArticlePanel = newPanel;
   }

Thanks to martin-g @ #wicket.

Regards,
Stephan

Am 11.11.2009 um 16:18 schrieb srm:

> Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:
> 
>> If you reload the page when selecting the element, instead of using AJAX, I
>> guess the same will work because you have a selected article... I think AJAX
>> is just a detail here, maybe you can use
>> 
>> protected boolean wantOnSelectionChangedNotifications()
>>   {
>>       return false;
>>   }
>> 
>> on DropDownChoice?
>> 
> 
> 
> From my understanding, I need wantOnSelectionChangedNotifications()
> returning TRUE, otherwise onSelectionChanged() is never triggered.
> My current approach as follows. That's working but it doesn't feel right.
> To clumsy. Any ideas? (and I beg your pardon for mixing german 
> with english in the code ;) )
> 
> package view;
> 
> ..some imports...
> public class AddArticlePage extends StorePage {
> 
>  private AddArticlePanel addArticlePanel;
> 
>  @SuppressWarnings("unchecked")
>  public AddArticlePage() {
>   addArticlePanel = new AddArticlePanel("addArticlePanel");
>   addArticlePanel.setVisible(false);
>   DropDownChoice dropDownType = new DropDownChoice("dropDownType",
>     new PropertyModel(this, "selected"), Artikel.TYPELIST) {
>    protected boolean wantOnSelectionChangedNotifications() {
>                return true;
>            }
>    @Override
>    protected void onSelectionChanged(final Object newSelection) {
>     System.out.println("SELECTION CHANGED!");
>     System.out.println("new Selection = " + (String) newSelection);
>     addArticlePanel.setVisibleFields((String) newSelection);
>     addArticlePanel.setVisible(true);
>    }
>   };
> 
>   Form formAdd = new Form("addArticleForm") {
>    @Override
>    protected void onSubmit() {
>     System.out.println("Added Article...");
>    }
>   };
> 
>   add(dropDownType);
>   add(addArticlePanel);
>   add(formAdd);
>   
>  }
> }
> 
> 
> /***** THE PANEL CLASS ******/
> public class AddArticlePanel extends Panel {
> 
>  private TextField artikelNummer;
>  private TextField preis;
>  private TextField erscheinungsJahr;
>  private TextField beschreibung;
>  private TextField titel;
>  
>  //fields for BOOK
>  private TextField isbn; 
>  private TextField autor;
>  private TextField verlag;
>  
>  //fields for CD
>  private TextField label;
>  private TextField artist;
>  
>  public AddArticlePanel(String id) {
>   super(id);
>   
>   artikelNummer = new TextField("artikelNummer", new Model());
>   preis = new TextField("preis", new Model());
>   erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
>   beschreibung = new TextField("beschreibung", new Model());
>   titel = new TextField("titel", new Model());
>   isbn = new TextField("isbn", new Model());
>   autor = new TextField("autor", new Model());
>   verlag = new TextField("verlag", new Model());
>   label = new TextField("label", new Model());
>   artist = new TextField("artist", new Model());
>   add(artikelNummer);
>   add(preis);
>   add(erscheinungsJahr);
>   add(beschreibung);
>   add(titel);
>   add(isbn);
>   add(autor);
>   add(verlag);
>   add(label);
>   add(artist);
> 
> // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
> // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
> // SOUNDS AWFULL!
>   
>  }
>   
>        //could probably be optimised
>  public void setVisibleFields(String type) {
>   if (type.equals("BOOK")) {
>    isbn.setVisible(true);
>    autor.setVisible(true);
>    verlag.setVisible(true);
>    
>    label.setVisible(false);
>    artist.setVisible(false);
>   }
>   else {
>    isbn.setVisible(false);
>    autor.setVisible(false);
>    verlag.setVisible(false);
>    
>    label.setVisible(true);
>    artist.setVisible(true);
>   }
>  }
>  
> 
> }
> 
> Comments please :)
> 
> 
>> Best,
>> 
>> Ernesto
>> 
>> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
>> 
>>> 
>>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>>> 
>>>> I have used something similar to
>>> [snip]
>>> [snap]
>>>> 
>>>> for such situations... I delegate creation to a factory class (so that
>>> new
>>>> products can be plugged in).
>>>> 
>>>> Best,
>>>> 
>>>> Ernesto
>>>> 
>>> 
>>> 
>>> Thank you for this example.
>>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>>> 
>>> Regards,
>>> Stephan
>>> 
>>> 
>>> 
>>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>>> 
>>>>> How would you approach the following:
>>>>> PageA is used to insert an article. At first, the user chooses what kind
>>> of
>>>>> article to insert (DropDownChoice).
>>>>> When the User made his choice, a coresponding form should be
>>> loaded/visible
>>>>> underneath the
>>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>>> holds
>>>>> all fields for any kind of article
>>>>> and make them visible depending on what the user has chosen (using
>>>>> onSelectionChanged).
>>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>>> this.
>>>>> 
>>>>> Further information will be happily provided.
>>>>> 
>>>>> Regards,
>>>>> Stephan
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro:

> If you reload the page when selecting the element, instead of using AJAX, I
> guess the same will work because you have a selected article... I think AJAX
> is just a detail here, maybe you can use
> 
> protected boolean wantOnSelectionChangedNotifications()
>    {
>        return false;
>    }
> 
> on DropDownChoice?
> 


From my understanding, I need wantOnSelectionChangedNotifications()
returning TRUE, otherwise onSelectionChanged() is never triggered.
My current approach as follows. That's working but it doesn't feel right.
To clumsy. Any ideas? (and I beg your pardon for mixing german 
with english in the code ;) )

package view;

..some imports...
public class AddArticlePage extends StorePage {

	private AddArticlePanel addArticlePanel;

	@SuppressWarnings("unchecked")
	public AddArticlePage() {
		addArticlePanel = new AddArticlePanel("addArticlePanel");
		addArticlePanel.setVisible(false);
		DropDownChoice dropDownType = new DropDownChoice("dropDownType",
				new PropertyModel(this, "selected"), Artikel.TYPELIST) {
			protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
			@Override
			protected void onSelectionChanged(final Object newSelection) {
				System.out.println("SELECTION CHANGED!");
				System.out.println("new Selection = " + (String) newSelection);
				addArticlePanel.setVisibleFields((String) newSelection);
				addArticlePanel.setVisible(true);
			}
		};

		Form formAdd = new Form("addArticleForm") {
			@Override
			protected void onSubmit() {
				System.out.println("Added Article...");
			}
		};

		add(dropDownType);
		add(addArticlePanel);
		add(formAdd);
		
	}
}


/***** THE PANEL CLASS ******/
public class AddArticlePanel extends Panel {

	private TextField artikelNummer;
	private TextField preis;
	private TextField erscheinungsJahr;
	private TextField beschreibung;
	private TextField titel;
	
	//fields for BOOK
	private TextField isbn; 
	private TextField autor;
	private TextField verlag;
	
	//fields for CD
	private TextField label;
	private TextField artist;
	
	public AddArticlePanel(String id) {
		super(id);
		
		artikelNummer = new TextField("artikelNummer", new Model());
		preis = new TextField("preis", new Model());
		erscheinungsJahr = new TextField("erscheinungsJahr", new Model());
		beschreibung = new TextField("beschreibung", new Model());
		titel = new TextField("titel", new Model());
		isbn = new TextField("isbn", new Model());
		autor = new TextField("autor", new Model());
		verlag = new TextField("verlag", new Model());
		label = new TextField("label", new Model());
		artist = new TextField("artist", new Model());
		add(artikelNummer);
		add(preis);
		add(erscheinungsJahr);
		add(beschreibung);
		add(titel);
		add(isbn);
		add(autor);
		add(verlag);
		add(label);
		add(artist);

// THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO
// DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION
// SOUNDS AWFULL!
		
	}
	 
        //could probably be optimised
	public void setVisibleFields(String type) {
		if (type.equals("BOOK")) {
			isbn.setVisible(true);
			autor.setVisible(true);
			verlag.setVisible(true);
			
			label.setVisible(false);
			artist.setVisible(false);
		}
		else {
			isbn.setVisible(false);
			autor.setVisible(false);
			verlag.setVisible(false);
			
			label.setVisible(true);
			artist.setVisible(true);
		}
	}
	

}

Comments please :)


> Best,
> 
> Ernesto
> 
> On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:
> 
>> 
>> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>> 
>>> I have used something similar to
>> [snip]
>> [snap]
>>> 
>>> for such situations... I delegate creation to a factory class (so that
>> new
>>> products can be plugged in).
>>> 
>>> Best,
>>> 
>>> Ernesto
>>> 
>> 
>> 
>> Thank you for this example.
>> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>> 
>> Regards,
>> Stephan
>> 
>> 
>> 
>>> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
>>> 
>>>> How would you approach the following:
>>>> PageA is used to insert an article. At first, the user chooses what kind
>> of
>>>> article to insert (DropDownChoice).
>>>> When the User made his choice, a coresponding form should be
>> loaded/visible
>>>> underneath the
>>>> DropDownChoice. That's all to be solved without JavaScript.
>>>> My current idea is currently to add an Panel (AddArticlePanel) which
>> holds
>>>> all fields for any kind of article
>>>> and make them visible depending on what the user has chosen (using
>>>> onSelectionChanged).
>>>> But that seems like a brute approach so I wanted to get your opinions on
>>>> this.
>>>> 
>>>> Further information will be happily provided.
>>>> 
>>>> Regards,
>>>> Stephan
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
If you reload the page when selecting the element, instead of using AJAX, I
guess the same will work because you have a selected article... I think AJAX
is just a detail here, maybe you can use

protected boolean wantOnSelectionChangedNotifications()
    {
        return false;
    }

on DropDownChoice?

Best,

Ernesto

On Wed, Nov 11, 2009 at 3:45 PM, srm <sr...@schokokeks.org> wrote:

>
> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:
>
> > I have used something similar to
> [snip]
> [snap]
> >
> > for such situations... I delegate creation to a factory class (so that
> new
> > products can be plugged in).
> >
> > Best,
> >
> > Ernesto
> >
>
>
> Thank you for this example.
> But I'm bound to not use Ajax/JavaScript...and now I'm stuck.
>
> Regards,
> Stephan
>
>
>
> > On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
> >
> >> How would you approach the following:
> >> PageA is used to insert an article. At first, the user chooses what kind
> of
> >> article to insert (DropDownChoice).
> >> When the User made his choice, a coresponding form should be
> loaded/visible
> >> underneath the
> >> DropDownChoice. That's all to be solved without JavaScript.
> >> My current idea is currently to add an Panel (AddArticlePanel) which
> holds
> >> all fields for any kind of article
> >> and make them visible depending on what the user has chosen (using
> >> onSelectionChanged).
> >> But that seems like a brute approach so I wanted to get your opinions on
> >> this.
> >>
> >> Further information will be happily provided.
> >>
> >> Regards,
> >> Stephan
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro:

> I have used something similar to
[snip]
[snap]
> 
> for such situations... I delegate creation to a factory class (so that new
> products can be plugged in).
> 
> Best,
> 
> Ernesto
> 


Thank you for this example.
But I'm bound to not use Ajax/JavaScript...and now I'm stuck.

Regards,
Stephan



> On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:
> 
>> How would you approach the following:
>> PageA is used to insert an article. At first, the user chooses what kind of
>> article to insert (DropDownChoice).
>> When the User made his choice, a coresponding form should be loaded/visible
>> underneath the
>> DropDownChoice. That's all to be solved without JavaScript.
>> My current idea is currently to add an Panel (AddArticlePanel) which holds
>> all fields for any kind of article
>> and make them visible depending on what the user has chosen (using
>> onSelectionChanged).
>> But that seems like a brute approach so I wanted to get your opinions on
>> this.
>> 
>> Further information will be happily provided.
>> 
>> Regards,
>> Stephan
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


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


Re: How to dynamically display a Form depending on a DropDownChoice?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
I have used something similar to

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

import com.google.inject.Inject;


public class EditPanel extends Panel {

    private IArticleEditFactory factory;

    private IArticle selected;

    private Form<IArticle> form;

    /**
     * @param id
     */
    public EditPanel(String id) {
        super(id);
        setOutputMarkupId(true);

        form = new Form<IArticle>("form");
        DropDownChoice<IArticle> choice = new
DropDownChoice<IArticle>("article", new Model<IArticle>() {

            public IArticle getObject() {
                return EditPanel.this.selected;
            };

            public void setObject(IArticle object) {
                EditPanel.this.selected = object;
            };

        }, listWithArticles );

        choice.add(new OnChangeAjaxBehavior() {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                if(target != null) {
                    target.addComponent(EditPanel.this);
                }
            }
        });

        form.add(choice);
    }

    @Override
    protected void onBeforeRender() {
        if(selected != null) {
            form.addOrReplace(factory.createArticleEditPanel("content",
selected));
        } else {
            form.addOrReplace(new EmptyPanel("content"));
        }
        super.onBeforeRender();
    }

}

for such situations... I delegate creation to a factory class (so that new
products can be plugged in).

Best,

Ernesto

On Wed, Nov 11, 2009 at 2:53 PM, srm <sr...@schokokeks.org> wrote:

> How would you approach the following:
> PageA is used to insert an article. At first, the user chooses what kind of
> article to insert (DropDownChoice).
> When the User made his choice, a coresponding form should be loaded/visible
> underneath the
> DropDownChoice. That's all to be solved without JavaScript.
> My current idea is currently to add an Panel (AddArticlePanel) which holds
> all fields for any kind of article
> and make them visible depending on what the user has chosen (using
> onSelectionChanged).
> But that seems like a brute approach so I wanted to get your opinions on
> this.
>
> Further information will be happily provided.
>
> Regards,
> Stephan
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

How to dynamically display a Form depending on a DropDownChoice?

Posted by srm <sr...@schokokeks.org>.
How would you approach the following: 
PageA is used to insert an article. At first, the user chooses what kind of article to insert (DropDownChoice). 
When the User made his choice, a coresponding form should be loaded/visible underneath the 
DropDownChoice. That's all to be solved without JavaScript.
My current idea is currently to add an Panel (AddArticlePanel) which holds all fields for any kind of article
and make them visible depending on what the user has chosen (using onSelectionChanged).
But that seems like a brute approach so I wanted to get your opinions on this.

Further information will be happily provided.

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


Re: Force page reload/re-render

Posted by pieter claassen <pi...@gmail.com>.
Thanks for all the feedback. onBeforeRender() works like a charm.

Pieter

On Tue, Nov 10, 2009 at 2:51 PM, Michael O'Cleirigh
<mi...@rivulet.ca> wrote:
> Hi Pieter,
>
> Components that have .setVisible(false) will never be evaluated again
> automatically.  You  need to call .setVisible(true) on all that apply.
>
> One way would be control visibility in the base panel by overriding
> onBeforeRender() to handle all the cases in one place. e.g.
>
> class ControlPanel  extends Panel {
>
>   protected void onBeforeRender () {
>       Role role = getModelObject();
>
>       caseOnePanel.setVisible(false);
>       caseTwoPanel.setVisible (false);
>
>       if (role instanceof CaseOne) {
>            caseOnePanel.setVisible (true);
>       }
>       else if (role instanceof CaseTwo) {
>           caseTwoPanel.setVisible (true);
>      }
>  }
> }
>
> Or you could override .isVisible() in your sub panels to control when they
> are visible.
>
> I like the on before render way myself because there is no performance
> penalty if the visibility logic is complex (Component.isVisible() is called
> alot during the rendering phase).
>
> Regards,
>
> Mike
>>
>> To recap, I have a control panel visible on each and every page and in
>> that control panel, you can select the appropriate role you want to
>> use. Based on that role some menu items will be visible or not
>> (example below is correct). I am sure this problem has been solved
>> before :-0 as this is a very normal usecase for context sensitive
>> navigation.
>>
>> It seems that there is no way to force the page to re-render using
>> getPage()?
>>
>> Thanks for the feedback so far. I keep on coming up against this issue
>> and have not found a reasonable solution to the problem. The
>> javascript option seems to be best so far.
>>
>> Pieter
>>
>> On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
>> <re...@gmail.com> wrote:
>>
>>>
>>> Even if you re-render your page components that are not "dynamic" will
>>> not
>>> change their state: unless you create a new instance of the page, I
>>> guess.
>>> By this I mean.
>>>
>>> class MyPanel .... {
>>>      public MyPanel(id) {
>>>          PanelB panelB = new Panel("B");
>>>          panelB.setVisible(getSomeCondition());
>>>          ....
>>>      }
>>> }
>>>
>>> Even if condition getSomeCondition() change, and you re-render  MyPanel,
>>> or
>>> the whole page, panelB will still be not visible. So, if you want
>>> something
>>> to be dynamic you have to program it to be dynamic.
>>>
>>> Best,
>>>
>>> Ernesto
>>>
>>>
>>> On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen
>>> <pi...@gmail.com>
>>> wrote:
>>>
>>>>
>>>> Both of the suggestions I think requires me to modify the logic of the
>>>> controls (either to keep track of which ones need to be updated or by
>>>> placing the rendering logic in onBeforeRender()). I think this is a
>>>> lot of work for something relative straight forward and also any
>>>> changes to permission structures and I have to modify controls.
>>>>
>>>> Is there no way that I can mark a page obtained via getPage() as
>>>> requiring re-rendering? I tried getPage().dirty() before the
>>>> setResponsePage() but that didn't do anything.
>>>>
>>>> Thanks for the feedback though.
>>>> P
>>>>
>>>> On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos <pe...@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>>> re-render controls on the page.
>>>>>
>>>>> Where do you implement your control ( update logic )? Consider do it
>>>>> overriding Component.onBeforeRender method
>>>>>
>>>>> On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
>>>>> <pi...@gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> Hi Pedro,
>>>>>>
>>>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>>>> re-render controls on the page.
>>>>>>
>>>>>> setResponsePage(getPage().getClass()) only works for stateless pages
>>>>>> and on most of my pages, I pass params via the constructor.
>>>>>>
>>>>>> The javascript option will be a last resort, but it seems to be not
>>>>>> the most elegant solution.
>>>>>>
>>>>>> Rgds,
>>>>>>
>>>>>> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> if(userSetWasChanged){
>>>>>>> target.appendJavascript("window.location.reload()");
>>>>>>> or
>>>>>>> setResponsePage(getPage());
>>>>>>> or
>>>>>>> setResponsePage(getPage().getClass());
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>>>>>>> <pi...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> I have a link on a panel that is included in many pages. When the
>>>>>>>> user
>>>>>>>> clicks on the link, I change something in the user settings that
>>>>>>>> will
>>>>>>>> affect what gets displayed on the page. However, for that to work, I
>>>>>>>> need to reload the page after the user clicked on the link as by
>>>>>>>> default the other components that now need to be checked for
>>>>>>>> conditional visibility don't re-render (why not?). setResponsePage()
>>>>>>>> requires me to pass into the panel a target page and this becomes
>>>>>>>> complex when you have a mix of statefull and stateless pages as
>>>>>>>> targets (and it just doesn't feel right).
>>>>>>>>
>>>>>>>> I am sure there must be an easier way to just re-render a page?
>>>>>>>>
>>>>>>>> Any tips?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> pieter
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Pedro Henrique Oliveira dos Santos
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Pieter Claassen
>>>>>> musmato.com
>>>>>>
>>>>>
>>>>> --
>>>>> Pedro Henrique Oliveira dos Santos
>>>>>
>>>>>
>>>>
>>>> --
>>>> Pieter Claassen
>>>> musmato.com
>>>>
>>>
>>>
>>
>>
>>
>>
>
>



-- 
Pieter Claassen
musmato.com

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


Re: Force page reload/re-render

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hi Pieter,

Components that have .setVisible(false) will never be evaluated again 
automatically.  You  need to call .setVisible(true) on all that apply.

One way would be control visibility in the base panel by overriding 
onBeforeRender() to handle all the cases in one place. e.g.

class ControlPanel  extends Panel {

    protected void onBeforeRender () {
        Role role = getModelObject();

        caseOnePanel.setVisible(false);
        caseTwoPanel.setVisible (false);

        if (role instanceof CaseOne) {
             caseOnePanel.setVisible (true);
        }
        else if (role instanceof CaseTwo) {
            caseTwoPanel.setVisible (true);
       }
   }
}

Or you could override .isVisible() in your sub panels to control when 
they are visible. 


I like the on before render way myself because there is no performance 
penalty if the visibility logic is complex (Component.isVisible() is 
called alot during the rendering phase).

Regards,

Mike
>
> To recap, I have a control panel visible on each and every page and in
> that control panel, you can select the appropriate role you want to
> use. Based on that role some menu items will be visible or not
> (example below is correct). I am sure this problem has been solved
> before :-0 as this is a very normal usecase for context sensitive
> navigation.
>
> It seems that there is no way to force the page to re-render using getPage()?
>
> Thanks for the feedback so far. I keep on coming up against this issue
> and have not found a reasonable solution to the problem. The
> javascript option seems to be best so far.
>
> Pieter
>
> On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
> <re...@gmail.com> wrote:
>   
>> Even if you re-render your page components that are not "dynamic" will not
>> change their state: unless you create a new instance of the page, I guess.
>> By this I mean.
>>
>> class MyPanel .... {
>>       public MyPanel(id) {
>>           PanelB panelB = new Panel("B");
>>           panelB.setVisible(getSomeCondition());
>>           ....
>>       }
>> }
>>
>> Even if condition getSomeCondition() change, and you re-render  MyPanel, or
>> the whole page, panelB will still be not visible. So, if you want something
>> to be dynamic you have to program it to be dynamic.
>>
>> Best,
>>
>> Ernesto
>>
>>
>> On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen <pi...@gmail.com>
>> wrote:
>>     
>>> Both of the suggestions I think requires me to modify the logic of the
>>> controls (either to keep track of which ones need to be updated or by
>>> placing the rendering logic in onBeforeRender()). I think this is a
>>> lot of work for something relative straight forward and also any
>>> changes to permission structures and I have to modify controls.
>>>
>>> Is there no way that I can mark a page obtained via getPage() as
>>> requiring re-rendering? I tried getPage().dirty() before the
>>> setResponsePage() but that didn't do anything.
>>>
>>> Thanks for the feedback though.
>>> P
>>>
>>> On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos <pe...@gmail.com> wrote:
>>>       
>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>> re-render controls on the page.
>>>>
>>>> Where do you implement your control ( update logic )? Consider do it
>>>> overriding Component.onBeforeRender method
>>>>
>>>> On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
>>>> <pi...@gmail.com> wrote:
>>>>         
>>>>> Hi Pedro,
>>>>>
>>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>>> re-render controls on the page.
>>>>>
>>>>> setResponsePage(getPage().getClass()) only works for stateless pages
>>>>> and on most of my pages, I pass params via the constructor.
>>>>>
>>>>> The javascript option will be a last resort, but it seems to be not
>>>>> the most elegant solution.
>>>>>
>>>>> Rgds,
>>>>>
>>>>> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com>
>>>>> wrote:
>>>>>           
>>>>>> if(userSetWasChanged){
>>>>>> target.appendJavascript("window.location.reload()");
>>>>>> or
>>>>>> setResponsePage(getPage());
>>>>>> or
>>>>>> setResponsePage(getPage().getClass());
>>>>>> }
>>>>>>
>>>>>>
>>>>>> On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>>>>>> <pi...@gmail.com>
>>>>>> wrote:
>>>>>>             
>>>>>>> I have a link on a panel that is included in many pages. When the
>>>>>>> user
>>>>>>> clicks on the link, I change something in the user settings that
>>>>>>> will
>>>>>>> affect what gets displayed on the page. However, for that to work, I
>>>>>>> need to reload the page after the user clicked on the link as by
>>>>>>> default the other components that now need to be checked for
>>>>>>> conditional visibility don't re-render (why not?). setResponsePage()
>>>>>>> requires me to pass into the panel a target page and this becomes
>>>>>>> complex when you have a mix of statefull and stateless pages as
>>>>>>> targets (and it just doesn't feel right).
>>>>>>>
>>>>>>> I am sure there must be an easier way to just re-render a page?
>>>>>>>
>>>>>>> Any tips?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> pieter
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>               
>>>>>>
>>>>>> --
>>>>>> Pedro Henrique Oliveira dos Santos
>>>>>>
>>>>>>             
>>>>>
>>>>> --
>>>>> Pieter Claassen
>>>>> musmato.com
>>>>>           
>>>>
>>>> --
>>>> Pedro Henrique Oliveira dos Santos
>>>>
>>>>         
>>>
>>> --
>>> Pieter Claassen
>>> musmato.com
>>>       
>>     
>
>
>
>   


Re: Force page reload/re-render

Posted by Pedro <pe...@gmail.com>.
The page will be re-rendered... Implement your menu item componentes  
isVisible method to return true due your context

Enviado de meu iPhone

Em 10/11/2009, às 11:39, pieter claassen <pi...@gmail.com>  
escreveu:

> Hi Ernesto,
>
> To recap, I have a control panel visible on each and every page and in
> that control panel, you can select the appropriate role you want to
> use. Based on that role some menu items will be visible or not
> (example below is correct). I am sure this problem has been solved
> before :-0 as this is a very normal usecase for context sensitive
> navigation.
>
> It seems that there is no way to force the page to re-render using  
> getPage()?
>
> Thanks for the feedback so far. I keep on coming up against this issue
> and have not found a reasonable solution to the problem. The
> javascript option seems to be best so far.
>
> Pieter
>
> On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
> <re...@gmail.com> wrote:
>> Even if you re-render your page components that are not "dynamic"  
>> will not
>> change their state: unless you create a new instance of the page, I  
>> guess.
>> By this I mean.
>>
>> class MyPanel .... {
>>       public MyPanel(id) {
>>           PanelB panelB = new Panel("B");
>>           panelB.setVisible(getSomeCondition());
>>           ....
>>       }
>> }
>>
>> Even if condition getSomeCondition() change, and you re-render   
>> MyPanel, or
>> the whole page, panelB will still be not visible. So, if you want  
>> something
>> to be dynamic you have to program it to be dynamic.
>>
>> Best,
>>
>> Ernesto
>>
>>
>> On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen <pieter.claassen@gmail.com 
>> >
>> wrote:
>>>
>>> Both of the suggestions I think requires me to modify the logic of  
>>> the
>>> controls (either to keep track of which ones need to be updated or  
>>> by
>>> placing the rendering logic in onBeforeRender()). I think this is a
>>> lot of work for something relative straight forward and also any
>>> changes to permission structures and I have to modify controls.
>>>
>>> Is there no way that I can mark a page obtained via getPage() as
>>> requiring re-rendering? I tried getPage().dirty() before the
>>> setResponsePage() but that didn't do anything.
>>>
>>> Thanks for the feedback though.
>>> P
>>>
>>> On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos  
>>> <pe...@gmail.com> wrote:
>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>> re-render controls on the page.
>>>>
>>>> Where do you implement your control ( update logic )? Consider do  
>>>> it
>>>> overriding Component.onBeforeRender method
>>>>
>>>> On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
>>>> <pi...@gmail.com> wrote:
>>>>>
>>>>> Hi Pedro,
>>>>>
>>>>> I tried setResponsePage(getPage()) but the problem is it does not
>>>>> re-render controls on the page.
>>>>>
>>>>> setResponsePage(getPage().getClass()) only works for stateless  
>>>>> pages
>>>>> and on most of my pages, I pass params via the constructor.
>>>>>
>>>>> The javascript option will be a last resort, but it seems to be  
>>>>> not
>>>>> the most elegant solution.
>>>>>
>>>>> Rgds,
>>>>>
>>>>> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pedrosans@gmail.com 
>>>>> >
>>>>> wrote:
>>>>>> if(userSetWasChanged){
>>>>>> target.appendJavascript("window.location.reload()");
>>>>>> or
>>>>>> setResponsePage(getPage());
>>>>>> or
>>>>>> setResponsePage(getPage().getClass());
>>>>>> }
>>>>>>
>>>>>>
>>>>>> On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>>>>>> <pi...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> I have a link on a panel that is included in many pages. When  
>>>>>>> the
>>>>>>> user
>>>>>>> clicks on the link, I change something in the user settings that
>>>>>>> will
>>>>>>> affect what gets displayed on the page. However, for that to  
>>>>>>> work, I
>>>>>>> need to reload the page after the user clicked on the link as by
>>>>>>> default the other components that now need to be checked for
>>>>>>> conditional visibility don't re-render (why not?).  
>>>>>>> setResponsePage()
>>>>>>> requires me to pass into the panel a target page and this  
>>>>>>> becomes
>>>>>>> complex when you have a mix of statefull and stateless pages as
>>>>>>> targets (and it just doesn't feel right).
>>>>>>>
>>>>>>> I am sure there must be an easier way to just re-render a page?
>>>>>>>
>>>>>>> Any tips?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> pieter
>>>>>>>
>>>>>>>
>>>>>>> --- 
>>>>>>> --- 
>>>>>>> ---------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Pedro Henrique Oliveira dos Santos
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Pieter Claassen
>>>>> musmato.com
>>>>
>>>>
>>>>
>>>> --
>>>> Pedro Henrique Oliveira dos Santos
>>>>
>>>
>>>
>>>
>>> --
>>> Pieter Claassen
>>> musmato.com
>>
>>
>
>
>
> -- 
> Pieter Claassen
> musmato.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Force page reload/re-render

Posted by pieter claassen <pi...@gmail.com>.
Hi Ernesto,

To recap, I have a control panel visible on each and every page and in
that control panel, you can select the appropriate role you want to
use. Based on that role some menu items will be visible or not
(example below is correct). I am sure this problem has been solved
before :-0 as this is a very normal usecase for context sensitive
navigation.

It seems that there is no way to force the page to re-render using getPage()?

Thanks for the feedback so far. I keep on coming up against this issue
and have not found a reasonable solution to the problem. The
javascript option seems to be best so far.

Pieter

On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro
<re...@gmail.com> wrote:
> Even if you re-render your page components that are not "dynamic" will not
> change their state: unless you create a new instance of the page, I guess.
> By this I mean.
>
> class MyPanel .... {
>       public MyPanel(id) {
>           PanelB panelB = new Panel("B");
>           panelB.setVisible(getSomeCondition());
>           ....
>       }
> }
>
> Even if condition getSomeCondition() change, and you re-render  MyPanel, or
> the whole page, panelB will still be not visible. So, if you want something
> to be dynamic you have to program it to be dynamic.
>
> Best,
>
> Ernesto
>
>
> On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen <pi...@gmail.com>
> wrote:
>>
>> Both of the suggestions I think requires me to modify the logic of the
>> controls (either to keep track of which ones need to be updated or by
>> placing the rendering logic in onBeforeRender()). I think this is a
>> lot of work for something relative straight forward and also any
>> changes to permission structures and I have to modify controls.
>>
>> Is there no way that I can mark a page obtained via getPage() as
>> requiring re-rendering? I tried getPage().dirty() before the
>> setResponsePage() but that didn't do anything.
>>
>> Thanks for the feedback though.
>> P
>>
>> On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos <pe...@gmail.com> wrote:
>> > I tried setResponsePage(getPage()) but the problem is it does not
>> > re-render controls on the page.
>> >
>> > Where do you implement your control ( update logic )? Consider do it
>> > overriding Component.onBeforeRender method
>> >
>> > On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
>> > <pi...@gmail.com> wrote:
>> >>
>> >> Hi Pedro,
>> >>
>> >> I tried setResponsePage(getPage()) but the problem is it does not
>> >> re-render controls on the page.
>> >>
>> >> setResponsePage(getPage().getClass()) only works for stateless pages
>> >> and on most of my pages, I pass params via the constructor.
>> >>
>> >> The javascript option will be a last resort, but it seems to be not
>> >> the most elegant solution.
>> >>
>> >> Rgds,
>> >>
>> >> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com>
>> >> wrote:
>> >> > if(userSetWasChanged){
>> >> > target.appendJavascript("window.location.reload()");
>> >> > or
>> >> > setResponsePage(getPage());
>> >> > or
>> >> > setResponsePage(getPage().getClass());
>> >> > }
>> >> >
>> >> >
>> >> > On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>> >> > <pi...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> I have a link on a panel that is included in many pages. When the
>> >> >> user
>> >> >> clicks on the link, I change something in the user settings that
>> >> >> will
>> >> >> affect what gets displayed on the page. However, for that to work, I
>> >> >> need to reload the page after the user clicked on the link as by
>> >> >> default the other components that now need to be checked for
>> >> >> conditional visibility don't re-render (why not?). setResponsePage()
>> >> >> requires me to pass into the panel a target page and this becomes
>> >> >> complex when you have a mix of statefull and stateless pages as
>> >> >> targets (and it just doesn't feel right).
>> >> >>
>> >> >> I am sure there must be an easier way to just re-render a page?
>> >> >>
>> >> >> Any tips?
>> >> >>
>> >> >> Thanks,
>> >> >> pieter
>> >> >>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Pedro Henrique Oliveira dos Santos
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Pieter Claassen
>> >> musmato.com
>> >
>> >
>> >
>> > --
>> > Pedro Henrique Oliveira dos Santos
>> >
>>
>>
>>
>> --
>> Pieter Claassen
>> musmato.com
>
>



-- 
Pieter Claassen
musmato.com

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


Re: Force page reload/re-render

Posted by pieter claassen <pi...@gmail.com>.
Both of the suggestions I think requires me to modify the logic of the
controls (either to keep track of which ones need to be updated or by
placing the rendering logic in onBeforeRender()). I think this is a
lot of work for something relative straight forward and also any
changes to permission structures and I have to modify controls.

Is there no way that I can mark a page obtained via getPage() as
requiring re-rendering? I tried getPage().dirty() before the
setResponsePage() but that didn't do anything.

Thanks for the feedback though.
P

On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos <pe...@gmail.com> wrote:
> I tried setResponsePage(getPage()) but the problem is it does not
> re-render controls on the page.
>
> Where do you implement your control ( update logic )? Consider do it
> overriding Component.onBeforeRender method
>
> On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen
> <pi...@gmail.com> wrote:
>>
>> Hi Pedro,
>>
>> I tried setResponsePage(getPage()) but the problem is it does not
>> re-render controls on the page.
>>
>> setResponsePage(getPage().getClass()) only works for stateless pages
>> and on most of my pages, I pass params via the constructor.
>>
>> The javascript option will be a last resort, but it seems to be not
>> the most elegant solution.
>>
>> Rgds,
>>
>> On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com>
>> wrote:
>> > if(userSetWasChanged){
>> > target.appendJavascript("window.location.reload()");
>> > or
>> > setResponsePage(getPage());
>> > or
>> > setResponsePage(getPage().getClass());
>> > }
>> >
>> >
>> > On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
>> > <pi...@gmail.com>
>> > wrote:
>> >>
>> >> I have a link on a panel that is included in many pages. When the user
>> >> clicks on the link, I change something in the user settings that will
>> >> affect what gets displayed on the page. However, for that to work, I
>> >> need to reload the page after the user clicked on the link as by
>> >> default the other components that now need to be checked for
>> >> conditional visibility don't re-render (why not?). setResponsePage()
>> >> requires me to pass into the panel a target page and this becomes
>> >> complex when you have a mix of statefull and stateless pages as
>> >> targets (and it just doesn't feel right).
>> >>
>> >> I am sure there must be an easier way to just re-render a page?
>> >>
>> >> Any tips?
>> >>
>> >> Thanks,
>> >> pieter
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >
>> >
>> >
>> > --
>> > Pedro Henrique Oliveira dos Santos
>> >
>>
>>
>>
>> --
>> Pieter Claassen
>> musmato.com
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>



-- 
Pieter Claassen
musmato.com

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


Re: Force page reload/re-render

Posted by pieter claassen <pi...@gmail.com>.
Hi Pedro,

I tried setResponsePage(getPage()) but the problem is it does not
re-render controls on the page.

setResponsePage(getPage().getClass()) only works for stateless pages
and on most of my pages, I pass params via the constructor.

The javascript option will be a last resort, but it seems to be not
the most elegant solution.

Rgds,

On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos <pe...@gmail.com> wrote:
> if(userSetWasChanged){
> target.appendJavascript("window.location.reload()");
> or
> setResponsePage(getPage());
> or
> setResponsePage(getPage().getClass());
> }
>
>
> On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen <pi...@gmail.com>
> wrote:
>>
>> I have a link on a panel that is included in many pages. When the user
>> clicks on the link, I change something in the user settings that will
>> affect what gets displayed on the page. However, for that to work, I
>> need to reload the page after the user clicked on the link as by
>> default the other components that now need to be checked for
>> conditional visibility don't re-render (why not?). setResponsePage()
>> requires me to pass into the panel a target page and this becomes
>> complex when you have a mix of statefull and stateless pages as
>> targets (and it just doesn't feel right).
>>
>> I am sure there must be an easier way to just re-render a page?
>>
>> Any tips?
>>
>> Thanks,
>> pieter
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>



-- 
Pieter Claassen
musmato.com

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


Re: Force page reload/re-render

Posted by Pedro Santos <pe...@gmail.com>.
if(userSetWasChanged){
target.appendJavascript("window.location.reload()");
or
setResponsePage(getPage());
or
setResponsePage(getPage().getClass());
}


On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen
<pi...@gmail.com>wrote:

> I have a link on a panel that is included in many pages. When the user
> clicks on the link, I change something in the user settings that will
> affect what gets displayed on the page. However, for that to work, I
> need to reload the page after the user clicked on the link as by
> default the other components that now need to be checked for
> conditional visibility don't re-render (why not?). setResponsePage()
> requires me to pass into the panel a target page and this becomes
> complex when you have a mix of statefull and stateless pages as
> targets (and it just doesn't feel right).
>
> I am sure there must be an easier way to just re-render a page?
>
> Any tips?
>
> Thanks,
> pieter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: Force page reload/re-render

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Isn't AJAX  refresh an option to consider here? For instance, defining some
"contexts" which need to be re-rendered (e.g. marking them with an
interface) and them having and IVisitor that collects all those contexts and
add them to the AjaxRequestTarget?

Best,

Ernesto

On Tue, Nov 10, 2009 at 8:19 AM, pieter claassen
<pi...@gmail.com>wrote:

> I have a link on a panel that is included in many pages. When the user
> clicks on the link, I change something in the user settings that will
> affect what gets displayed on the page. However, for that to work, I
> need to reload the page after the user clicked on the link as by
> default the other components that now need to be checked for
> conditional visibility don't re-render (why not?). setResponsePage()
> requires me to pass into the panel a target page and this becomes
> complex when you have a mix of statefull and stateless pages as
> targets (and it just doesn't feel right).
>
> I am sure there must be an easier way to just re-render a page?
>
> Any tips?
>
> Thanks,
> pieter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>