Updates from April, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • Tomás Augusto Müller 11:02 am on April 16, 2010 Permalink | Reply
    Tags: , , jboss-el, , seamframework   

    Read query string using jsf, facelets and Seam-EL 

    If you are familiar with JavaServer Faces, maybe already read or heard someone talk about JSF implicit objects.
    In short, an implicit object is similar to a managed bean, but one that is created and maintained by the JSF engine, which you may make reference to with EL.

    The implicit EL object #{facesContext} maintained by the JSF servlet is instantiated from javax.faces.context.FacesContext, for each JSF request made upon the mid-tier. As the JSF lifecycle processes the current JSF request, the FacesContext instance carries the information about the page to be rendered, essentially the JSF response to the original request.

    You can use this object to retrieve a reference to the request parameter map (which is a Map<String, String>) and through the JBoss-EL, access the value of the desired param.

    Example:

    GET request to: http://localhost:8080/yourApp/yourPage.seam?param1=value%201&param2=1234

    <h:outputText value=”#{facesContext.externalContext.requestParameterMap.get(‘param1′)}” />

    output: value 1

    <h:outputText value=”#{facesContext.externalContext.requestParameterMap.get(‘param2′)}” />
    output: 1234

    Tip: there is also the #{param} implicit object. You can use this reference to grap your query string parameters in a short form as follows:

    <h:outputText value=”#{param.get(‘parameterNameHere’)}” />

    As you may be wondering, there are several other implicit objects. You can check them bellow.

    • facesContext – The FacesContext instance for the current request.
    • param – Maps a request parameter name to a single value.
    • paramValues – Maps a request parameter name to an array of values.
    • header – Maps a request header name to a single value.
    • headerValues – Maps a request header name to an array of values.
    • cookie – Maps a cookie name to a single cookie.
    • initParam – Maps a context initialization parameter name to a single value.
       

    Objects that allow access to various scoped variables:

    • requestScope – Maps request-scoped variable names to their values.
    • sessionScope – Maps session-scoped variable names to their values.
    • applicationScope – Maps application-scoped variable names to their values.
       

    When an expression references one of these objects by name, the appropriate object is returned. An implicit object takes precedence over an attribute that has the same name. For example, #{facesContext} returns the FacesContext object, even if there is an existing facesContext attribute containing some other value.

    source: http://developers.sun.com/docs/jscreator/help/jsp-jsfel/jsf_expression_language_intro.html#implicitobjects

     
  • Tomás Augusto Müller 10:28 pm on January 13, 2010 Permalink | Reply
    Tags: , ,   

    Facelets “com.sun.facelets.impl.DefaultFacelet refresh” error 

    If you are getting this error, just add the following parameter to your web.xml file:

        <context-param>
            <param-name>facelets.REFRESH_PERIOD</param-name>
            <param-value>-1</param-value>
        </context-param>

    facelets.REFRESH_PERIOD
    When a page is requested, what interval in seconds should the compiler check for changes. If you don’t want the compiler to check for changes once the page is compiled, then use a value of -1. Setting a low refresh period helps during development to be able to edit pages in a running application.
    Default value: 2

    More info at:
    https://facelets.dev.java.net/nonav/docs/dev/docbook.html#config-webapp-init
    http://old.nabble.com/Error:-Facelet-was-modified,-flushing-component-applied-td13500808.html

     
    • Tapas Kr. Dey 2:17 am on August 9, 2011 Permalink

      Thank you.It helps me very well.

  • Tomás Augusto Müller 10:26 pm on January 13, 2010 Permalink | Reply
    Tags: , ,   

    How to use Javascript script tag in Facelets xhtml file 

    If you want to use javascript, with the <script> tag in Facelets xhtml file, and your script have characters like ‘>’, ‘<’, you may get this error message:

    com.sun.facelets.FaceletException: Error Parsing /filename.xhtml: Error Traced[line: xx]
    The content of elements must consist of well-formed character data or markup.

    To avoid this parsing error use the script in a "commented" way:

    <script type="text/javascript">
    <!--
    your script here.
    //-->
    </script>
     
    • Jitesh 9:11 am on September 16, 2010 Permalink

      Thanx a lot

    • Fernando 2:10 am on April 2, 2011 Permalink

      thanks for the tip! very helpfull

    • Federico González Brizzio 11:57 am on May 3, 2011 Permalink

      Thank you!

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.