Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
857 views
in Technique[技术] by (71.8m points)

jsf - The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>

I am getting the following error on my Facelet page, which simply consists of an IceFaces form with two fields and two buttons:

The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>

Here is the form:

<ice:form id="form1" partialSubmit="false">
    <ice:panelLayout id="panelLayout3">
        <ice:graphicImage id="graphicImage1" url="/resources/images/LoginImage.jpg" width="560" />
        <ice:outputLabel for="j_username" id="outputLabel1" value="Username:"/>
        <ice:outputLabel for="j_password" id="outputLabel2" value="Password:"/>
        <ice:inputText binding="#{login.username}" id="j_username" required="true" />
        <ice:inputSecret binding="#{login.password}" id="j_password" required="true" />
        <ice:commandButton  actionListener="#{login.login}" id="loginBtn" value="Login"/>
        <ice:commandButton action="#{login.reset}" id="resetBtn" value="Reset"/>
        <ice:outputText id="errorMessage" />
        <ice:message errorClass="errorMessage" for="j_username" fatalClass="fatalMessage" id="messages1" infoClass="infoMessage" showSummary="false" warnClass="warnMessage"/>
    </ice:panelLayout>
</ice:form>

How is this caused and how can I solve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is not an error. This is a warning. The code looks fine, all input components are inside a form, it seems that it should run and work fine. If it indeed works fine, just ignore the warning. This warning is displayed only when the context parameter javax.faces.PROJECT_STAGE is set to Development anyway .

As to the false warning message itself, this check was introduced in Mojarra 2.1.1 as per issue 1663. However, as per issue 2147 it turns out to have some bugs and is been further improved in Mojarra 2.1.3. I'd imagine that the false warning is in your particular case caused by having an <ice:panelLayout> between the form and the input elements.

If you aren't on Mojarra 2.1.3 yet, you may want to consider upgrading to see if it removes the false warning message.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...