Dynamic Titles

Craig has resumed blogging. In his first new blog entry he's talking about the new Data Provider APIs in Creator 2 - which allow you to drag & drop not only database tables, but EJB methods, and web services to automatically data bind to visual components.

The Data Providers also allow you to map the components to your own data structures - or connect the components to other persistence technologies or frameworks. One of my earlier blog entries talked about how to do this with the standard JSF data table in Creator 1.0. With the new data providers it should be a lot easier. However, we have some EA bugs which makes it a bit tricky at the moment. Perhaps Craig's next blog will show how to do it specifically - if not, I'll take a stab at it.

It's been a really great week in Creator engineering. We've been doing memory profiling and have found some major culprits. We're not done with the performance work though.

I'll finish this entry with a tip: How to generate dynamic titles for your pages. Page titles of course are typically shown by browsers in their window titlebars - and they usually also become the default bookmark label.

This used to be tricky (in Creator 1.0). In Creator 2, all you need to do is locate the Head component in the Outline. Notice that it has a Title property. All you need to do is set this property to a value binding expression, for example #{Page1.title}, and then add this method to Page1's java file:

    public String getTitle() {
        return "Dynamic Title " + new java.util.Date().toString();
    }

Title bar screenshot

For those of you who are using Creator 1.0, the way you need to do it is to add the same method to the page bean, but then switch to the JSP file, and locate the <title> tag. Remove the text which is in there, and add this:

   <h:outputText value="#{Page1.title}"/>

Note that this output text doesn't have an id, and doesn't have a binding attribute. That's important, because this means that the output text will emit the text returned by the value binding expression as a simple text string, rather than wrapping it in a <span> inside the title element as it would otherwise do.

Comments:

Post a Comment:
Comments are closed for this entry.
About

Tor Norbye

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today