RhigoHR
RhigoHR

Reputation: 81

Is there any problem when I mix JSF with plain HTML?

I have the next code:

<li>
    <h:form rendered="#{!loginController.session}">
        <h3>Inicio de Sesi&oacute;n</h3>
        <h:panelGrid columns="2" cellpadding="7">
            <h:outputText value="Usuario: " />
            <h:inputText id="loginname" value="#{loginController.loginname}" maxlength="16" />
            <h:outputText value="Contrase&ntilde;a: " />
            <h:inputSecret id="password" value="#{loginController.password}" maxlength="16"/>
            <h:outputText value="" />
            <h:commandButton value="Iniciar Sesi&oacute;n" action="#{loginController.CheckValidUser}"    />
        </h:panelGrid>
    </h:form>
</li>

But when run that the page doesn't render the form, anybody can tell me why?

Upvotes: 1

Views: 1729

Answers (1)

BalusC
BalusC

Reputation: 1108722

If you're using the ancient JSF 1.0/1.1 implementations, then you need to wrap HTML in <f:verbatim> tags like so:

<f:verbatim><li></f:verbatim>
    <h:form rendered="#{!loginController.session}">
        <f:verbatim><h3>Inicio de Sesi&oacute;n</h3></f:verbatim>
        <h:panelGrid columns="2" cellpadding="7">
            ...

Otherwise they will end up in the top of the generated document, before all JSF components.

If you're using a JSF 1.2 implementation or newer, then you should be able to write plain HTML in template text without problems since they are automatically taken as verbatim in the component tree. The only cause for the form not being rendered would be that LoginController#isSession() returned true since that's what its rendered attribute is depending on.

Upvotes: 5

Related Questions