Playing with titlebar and navigator

My next quest was to change content of titlebar and navigator box. Titlebar was really easy, but navigator box is 'hell itself', because it's r:navigator component and i didn't want to create another component just for adding one more line.

Titlebar editing is very easy. Final result is on following screenshot:

Image and video hosting by TinyPic

That topmenu is created by a styled a:modeList component with some listItems. ModeList has actionListener set and after listItem is clicked, its value is sent to that listener (which is a big switch). So my first task was to bridge that listener. Original code is placed in NavigationBean and that method is named toolbarLocationChanged. I wrote my own eventListener in 'someBean' this way:

public void toolbarLocationChanged(ActionEvent event){
     UIModeList locationList = (UIModeList)event.getComponent();
     String location = locationList.getValue().toString();
      . . .
      }else this.navigator.processToolbarLocation(location, true);

In this piece of code is loaded 'location' – value of listItem (ie companyhome, userhome, archivace… see later) and is compared with identificator of my action.If equals, something happens (see next listing ;-)), else original processToolbarLocation routine in NavigationBean is called.

That something piece of code, which happens in that case is creation of breadcrumb and some informations in NavigationBean are changed, follows here:

List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
Node archivace = new Node(getArchivaceRef());
elements.add(new NavigationBreadcrumbHandler(archivace.getNodeRef(), archivace.getName()));

But that is not all, you have to inform registered beans that the current area has changed:


And because the current node is not added to the dispatch context automaticaly, it's needed to add it programaticaly (this was very old bug of Alfresco and in some cases still lasts – forum, jira):


Last thing to do is to force a navigation to refresh the browse screen breadcrumb:

FacesContext context = FacesContext.getCurrentInstance();
 context.getApplication().getNavigationHandler().handleNavigation(context, null, "browse");

 That's all java coding. Now some jsp: you have to edit file titlebar.jsp in /jsp/parts/ and change actionListener in a:modeList and add another a:listItem as seen on next listing (simplified):

<a:modeList . . . actionListener="#{SomeBean.toolbarLocationChanged}">
      <a:listItem value="archivace" label="Archivace" rendered="#{SomeBean.isArchivaceExist}"/>

Ah, I see there is evaluator – isArchivaceExist. It's just an evaluator, which returns true/false – if space I want to view exists, so that listItem is viewed just in case of that space exists.


As I can see, it'll be better to move navigator hacks to next blogpost.

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *