Here is my form:
<form action="j_security_check">
<h:panelGrid columns="2" bgcolor="#eff5fa" cellspacing="5" frame="box" styleClass="center">
<h:outputLabel value="User ID:"/>
<h:inputText id="j_username" tabindex="1" />
<h:outputLabel value="Password:"/>
<h:inputSecret id="j_password"/>
<h:outputLabel value=""/>
<h:commandButton id="login" value="Login"/>
</h:panelGrid>
</form>
It work fine with Glassfish 3.0.1, but since Glassfish 3.1 b2 it shows this warning as a FacesMessage
in the JSF page:
The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within
<h:form>
If I change the <form action="j_security_check">
to <h:form>
, it does not fix it, I have to place the <h:form>
inside the <h:panelGrid>
.
It only shows if you are in JSF Development based on your web config.
When you change it to Production it wont show anymore
I'm using Mojarra 2.1.27 and find out that this is my mistakes. However its just very hard to find what the mistakes was. Hopefully someone from Mojarra could add component id to the warning messages. Here is what I did to found out the component: (which also posted to https://code.google.com/p/primefaces/issues/detail?id=1586#c48)
I trace it by downloading the Mojarra source code and adding break point to com.sun.faces.context.FacesContextImpl class in method: public void addMessage(String clientId, FacesMessage message). when the break point catch, open the Debugging window or call stack window to find out that it was called by class com.sun.faces.application.view.FormOmittedChecker in method private static void addFormOmittedMessage(FacesContext context) which is previously called by method
public static void check(FacesContext context).
inside the check method there is parameter variable component. You can get the component id from Watch or variable window and then trace it back to your html page and code.
Its a hard way, but hope you can find the root of the problems. It will be much more simpler if the warning message also display the problematic component id
If anyone will find this usefull one day, i had same error and the problem was that i have primefaces component
and that component was not inside
<h:form>
elementThis is just a Warning not an Error. Warnings are usually there to inform the developer about unforeseen situations/conditions which might not immediately cause technical errors/problems. Anything may just work flawlessly, but the behaviour/results may probably not be as the developer intented. A newbie developer may for example accidently have used
<form>
instead of<h:form>
. Warnings like this are then helpful.In your particular case, you are simply forced to use
<form>
because of the need to submit to a non-JSF service. You as a more experienced developer know that it's legitimately valid. You can just ignore this warning. This warning will only appear whenjavax.faces.PROJECT_STAGE
is set toDevelopment
anyway and not appear when it is set toProduction
.However, that it still displays the warning when there's another component like panelgrid in between the form and its input children, is a bug to me. I'd report it to the Mojarra guys. It look like as if it is checking the immediate parent only and not all of the parents. Update: it has been fixed as per Mojarra 2.1.3/2.2, see also issue 2147.
This is by the way not Glassfish specific. The newer GF version of course ships with a newer Mojarra version which has those warnings implemented. See also issue 1663.
Related questions:
This was suggested to me by Oleg from the PrimeFaces forum and works:
Regards, Brendan.
In my case, this warning message was displayed in
p:messages
which I've put in dialog to show validation errors, so I've just includedseverity="error"
inp:messages
and warning message was gone.