JSF with generated HTML


Web tier: servlets, JSP, Web frameworks: JSF with generated HTML

  1. JSF with generated HTML (1 messages)

    Hi, I'm just starting with JSF and I have a problem capturing data in the bean from simple html.

    If I use JSF tags to generate a text box, I am able to capture the value submitted in the Bean, but If I replace the jsf tags with plain html, the data posted back is not captured in the Bean.

    I replaced

    <h:inputText id="firstName" value="#{TestBean.firstName}" required="true" size="20"></h:inputText>

    the above line with

      <input id="testBean:firstName" type="text" name="testBean:firstName" size="20" />

    If you observe the html above is actually what is generated by the JSF tag.
    So what am I doing wrong ?

    Thanks for your time.
    - A
  2. JSF with generated HTML[ Go to top ]

    The problem is that without the <h:input> tag in the view definition no component will exist in the component tree to take the value of the field.
    You can if you really need to get to the value on the request using the getExternalContext() method on FacesContext.
    However, I don't see why you'd ever want to work this way, the best way to build pages with Faces is to treat them as XML documents and forget they are JSP don't be tempted to use scriptlets or JSTL or raw HTML tags unless you really have to.