3 Replies Latest reply on Aug 22, 2006 11:01 PM by gavin.king

    UI Labels and displaying the hash sign #

    zzzz8

      I can't seem to display the hash character

      In my JSP page, I have the following:

      <h:outputText escape="true" value="#{messages['TestNumber']}" />


      In my messages.properties file, I have:

      TestNumber=Test #


      Seam cannot evaluate the EL...

      Cannot get value for expression '#{messages['RequestNumber.Short']}'


      I've also tried the Unicode character for the hash sign:

      TestNumber=Test \u0023


      On an interesting note (just to test), if I tried another Unicode character like the left arrow (\u2190), then it does display the left arrow...

      If I change the label to (i.e. without the hash sign #):
      TestNumber=Test Number


      then everything is OK. Is this a bug in Seam or is there another way of doing this? I previously didn't have this problem in my JSF project until I added JBoss Seam. TIA.

        • 1. Re: UI Labels and displaying the hash sign #
          zzzz8

          Oops, that was a typo:

          Cannot get value for expression '#{messages['RequestNumber.Short']}'


          should have been:

          Cannot get value for expression '#{messages['TestNumber']}'


          The error still occurs...notwithstanding my bumbling copy and paste.

          • 2. Re: UI Labels and displaying the hash sign #
            raja05

            I think thats a seam bug. Seam tries to interpolate any expressions in the message bundle values and since it found a "#" in there, it seems to be looking for characters next to it, which wont be there in your case. Here is the snippet from Interpolator.interpolate thats causing the bug

             FacesContext context = FacesContext.getCurrentInstance();
             StringTokenizer tokens = new StringTokenizer(string, "#{}", true);
             StringBuilder builder = new StringBuilder(string.length());
             while ( tokens.hasMoreTokens() )
             {
             String tok = tokens.nextToken();
             if ( "#".equals(tok) )
             {
             String nextTok = tokens.nextToken();
            


            which would fail in your case. Other than filing a bug, the one option you have is to split your message content to have just the "Test" portion and include the "#" directly in your jsp page.



            • 3. Re: UI Labels and displaying the hash sign #
              gavin.king

              I believe I already made this more robust in CVS. Try a current CVS build.