Hey Paul,

thanks for your reply.

Sadly i can not use Behavior.configure(Component). The code will be executed (see Component.configure) before the render action is granted to the component by applying the isActionAuthorized(Render).
See Component.java line 1030 to 1039 for details.

Do i have another option?

Thanks
Per

Am 02.01.2014 16:55, schrieb Paul Bors:
Do you want the "configuration" code to run each time before the component
your behavior is attached to renders?
Then go ahead and place your code there, otherwise if you only want the
"configuration" code to run only once see the onConfigure() method:

/**
   * Called immediately after the onConfigure method in a component. Since
this is before the
   * rendering cycle has begun, the behavior can modify the configuration of
the component (i.e.
   * setVisible(false))
   *
   * @param component
   *            the component being configured
   */
  public void onConfigure(Component component)
  {
  }


On Thu, Jan 2, 2014 at 4:00 AM, Per Newgro <per.new...@gmx.ch> wrote:

Hi,

we have an admin menu in our menu bar. All items in admin menu are
configured by @AuthorizeAction.
I would like to hide the admin item in main menu if no menu item is
visible in the admin menu (e.g. user is not an admin).

To avoid repeating myself in every onBeforeRender method of the included
components i've tried to use a behavior.
It tries to hide parent by checking if all items are invisible and
configure the parent's visibility.

But this is not working (configure(component) and beforeRender(component)).
Configure is not usable because the render permission (setRenderAllowed)
is determined after the Behavior.onConfigure was called.
So the action takes place before the child is authorized.

Then i thaught let's do it in beforeRender. But there we got a message

org.apache.wicket.WicketRuntimeException: Cannot modify component
hierarchy after render phase has started (page version cant change then
anymore)
at org.apache.wicket.Component.checkHierarchyChange(Component.java:3595)
at org.apache.wicket.Component.addStateChange(Component.java:3524)
at org.apache.wicket.Component.setVisible(Component.java:3213)

This is comprehensible for me so far. No change after rendering started.
But how shall i hide the parent without repeating myself in
every Component.onBeforeRender method? This is working. But i have to
duplicate my code for ListItem, ListView and AdminPanel.

We use wicket-6.11

Thanks for helping me out of the wood.
Per

Here some markup of my admin menu markup.
<code>
<html xmlns:wicket>
     <wicket:panel>
         <a href="#" data-dropdown-toggle="#admin-navigation"
wicket:message="title:navigation.fullHeading.administration">
             <i class="icon-admin">?</i>
         </a>
         <div id="admin-navigation">
             <ul>
                 <wicket:container wicket:id="items">
                     <wicket:enclosure child="menu-item">
                         <li>
                             <a wicket:id="menu-item">
                                 <span>
                                     <wicket:container
wicket:id="short-title">Short title</wicket:container>
                                 </span>
                             </a>
                         </li>
                     </wicket:enclosure>
                 </wicket:container>
                 <wicket:enclosure child="reindexSearch">
                     <li>
                         <a wicket:id="reindexSearch"
onclick="alert('Rebuild initiated'); return true;">
                             <wicket:message 
key="navigation.fullHeading.reindex">Reindex
Search Server</wicket:message>
                         </a>
                     </li>
                 </wicket:enclosure>
             </ul>
         </div>
     </wicket:panel>
</html>
<code>

In page menu is included this way:
<code>
...
<ul class="button-toolbar" id="main-navigation">
   <wicket:container wicket:id="buttonMenu"></wicket:container>
   <wicket:enclosure child="adminNavigation">
     <li wicket:id="adminNavigation"></li>
   </wicket:enclosure>
</ul>
...
</code>


---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus
Schutz ist aktiv.
http://www.avast.com



---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz 
ist aktiv.
http://www.avast.com


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

Reply via email to