4 Replies Latest reply on Feb 16, 2007 10:04 AM by Alexander Radzishevsky

    Page Title

    John Varga Newbie

      Sorry for the dumb question, but I cannot seem to find where to set the Page Title (not each Portlets' Title). I always get "JBoss Portal 2.4.0-GA".

      Could someone point me to the document that holds that?

      tia.

        • 1. Re: Page Title
          Eric van Lydegraf Newbie

          Good question,

          I dug around and found the title is generated by the layout jsps

          server\default\deploy\jboss-portal.sar\portal-core.war\layouts\generic
          index.jsp
          maximized.jsp

          So quick and dirty is to replace that value
          or
          create a new layout id and clone and change the default set.

          But a much nicer way would be to have a page title property
          set in the deployment xml file.

          deployment/page elment would have (optional)
          page.title

          deployment/portal should have a default
          page.title (in case the page didn't define one)

          This way you get flexible global portal title or individual page titles

          This may already be doable, if someone could explain what objects are available in the layout jsps (e.g. how can one access Page properties?)

          • 2. Re: Page Title
            Woodler Expert

            It should be possible to write a jsp expression using the request attribute "PAGE" (LayoutConstants.ATTR_PAGE), which is of type org.jboss.portal.theme.page.PageResult . Use the getPageName() method on the PageResult. That should give you the name of the page as is was specified in the deployment descriptor, or in the admin UI.

            Disclaimer: Not tested ;)

            • 3. Re: Page Title
              Steve Jewett Newbie

              mholzner -

              I tried your suggestion and I get an error:

              An error occurred at line: 9 in the jsp file: /layouts/generic/index.jsp
              Generated servlet error:
              LayoutConstants.ATTR_PAGE cannot be resolved to a type


              This is what the beginning of my index.jsp page looks like:

              <%@ page import="org.jboss.portal.server.PortalConstants"%>
              <%@ page import="org.jboss.portal.theme.page.PageResult"%>
              <%@ taglib uri="/WEB-INF/theme/portal-layout.tld" prefix="p" %>
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
               <!-- <title><%= PortalConstants.VERSION.toString() %></title> -->
               <title><%= LayoutConstants.ATTR_PAGE.getPageName() %></title>
               <meta http-equiv="Content-Type" content="text/html;"/>
               <!-- to correct the unsightly Flash of Unstyled Content. -->
               <script type="text/javascript"></script>
               <!-- inject the theme; default to the Nphalanx theme if nothing is selected for the portal or the page -->
               <p:theme themeName='renaissance'/>
               <!-- insert header content that was possibly set by portlets on the page -->
               <p:headerContent/>
              </head>
              


              Do you see any obvious mistakes?

              I know you said it was untested . . . I just wondered if I was doing anything obviously wrong.

              Thanks!
              -Steve Jewett

              • 4. Re: Page Title
                Alexander Radzishevsky Newbie

                The following works (+ i18 support):

                <jsp:directive.page import="org.jboss.portal.theme.page.PageResult"/>
                <jsp:directive.page import="org.jboss.portal.theme.LayoutConstants"/>
                <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld"%>
                <%
                PageResult pageResult = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
                String pageNameKey = "PAGENAME_" + pageResult.getPageName();
                 %>
                <fmt:bundle basename="conf.bundles.Resource">
                <title><fmt:message key="<%=pageNameKey%>" /></title>
                </fmt:bundle>