Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run a JSF page without building the whole project?

Tags:

java

testing

jsf

Is there a way to just run the one page so that I can see the generated html (and css) as it would look to the user even if it is essentially non-functional? Standalone JSF page as it were. I want to review how I am setting up forms to see if they make sense form a user standpoint before actually coding for the form's fields. I'm using maven and netbeans but not sure if the latter is relevant.

like image 799
Bill Rosmus Avatar asked May 08 '12 18:05

Bill Rosmus


3 Answers

If you're using JSF2 Facelets, then you can just design your forms with plain HTML and use the jsfc attribute to specify the respective JSF component which should be used during JSF runtime. E.g.

<form jsfc="h:form">
    <label jsfc="h:outputLabel" for="input1" />
    <input type="text" jsfc="h:inputText" id="input1" value="#{bean.input1}" required="true" />
    <span jsfc="h:message" for="input1" />
    <input type="submit" jsfc="h:commandButton" value="Submit" action="#{bean.submit}" />
</form>

Reading the Facelets <ui:xxx> taglib documentation should also give some insights. E.g.

<span jsfc="ui:remove">
    This is present during design time, but is removed during JSF runtime.
</span>

<div jsfc="ui:repeat" value="#{bean.items}" var="item">#{item}</div>

<table>
    <tr jsfc="ui:repeat" value="#{bean.items}" var="item">
        <td>#{item.id}</td>
        <td>#{item.name}</td>
    </tr>
</table>

And the fact that you can use <ui:composition> to specify the start and end of a Facelet composition (e.g. an include file or a tag file). Any content outside will be disregarded during runtime, but you can still put some HTML around during designtime so that you can easily preview complete designs in which the include file or tag file is supposed to be part of.

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <head>
        ...
    </head>
    <body>
        ...
        <ui:composition>
            Here you can design content of include file or
            tag file as if it's part of the whole design.
        </ui:composition>
        ...
    </body>
</html>

This all allows you to preview HTML/CSS designs without needing a JSF runtime.

like image 64
BalusC Avatar answered Nov 05 '22 21:11

BalusC


JBoss Tools for Eclipse have rudimentary support for JSF-tags in their visual editor.

I played briefly with it, but it did not support our legacy pages fully, so I left it at that. It may work better when starting with a blank page.

like image 21
Thorbjørn Ravn Andersen Avatar answered Nov 05 '22 23:11

Thorbjørn Ravn Andersen


You can not execute a JSF page directly without deploying the built application. You have to deploy it, and only then will you be able to display executed the page.

like image 22
Bhavik Ambani Avatar answered Nov 05 '22 21:11

Bhavik Ambani