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
<reier...@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.claas...@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 <pedros...@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
<pieter.claas...@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 <pedros...@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
<pieter.claas...@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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to