If you use myfaces-1.1.5, you might have seen this error in you console. There are not too many sites presenting information about what’s causing this, and I struggled a bit myself trying to find out why my javascript console was flooded with this error message for each submit I did.
The problem appears if you have the org.apache.myfaces.AUTO_SCROLL parameter set to true, and you submit a form with one commandButton only. There is a JIRA-issue on it here, if you want some more specific information: MYFACES-1504. To give an example, this page would produce an error if AUTO_SCROLL is enabled:
<h:form id="myForm"> <t:commandButton id="submitMyFormButton" value="Submit" action="#{myHandler.myAction}" ></t:commandButton > </h:form>
There are no fixes to this problem yet (as of 20.01.2008), so until there is a version where this is corrected, simply add a hidden commandLink to the same form, and the problem goes away. You can’t hide it with the rendered attribute if myfaces, but have to hide it with css and styling:
<h:form id="myForm"> <t:commandButton id="submitMyFormButton" value="Submit" action="#{myHandler.myAction}" ></t:commandButton > <t:commandLink id="stupidHiddenButtonToAvoidException" value="Nothing" style="display: none; visibility: hidden;"></t:commandLink> </h:form>
31.01.2008 at 06:01:28
This is pretty well . but i want to reload a page without having IE open a popup saying to retry to resubmit the data again.
01.02.2008 at 09:02:55
This workaround has done the trick for us! We are use an enclosing tag (e.g. ) with the following code:
public void encodeChildren(FacesContext context) throws IOException {
//******** oamSetHiddenInput is not defined – temporarily solution ********
List childeren = getChildren();
HtmlCommandLink stupHiddenButtonToAvoidException = new HtmlCommandLink();
stupHiddenButtonToAvoidException.setValue(“Nothing”);
stupHiddenButtonToAvoidException.setStyle(“display: none; visibility: hidden”);
childeren.add(stupHiddenButtonToAvoidException);
//*****************************************************************************
…
}
01.02.2008 at 13:02:51
Marteyn, that’s a good workaround I hadn’t thought about 🙂 But still, very nice and simple. Thank you for sharing!
01.02.2008 at 14:02:19
hem, I didn’t get your problem properly. Are you saying that you do a post/submit, and then when you reload it pops up with a message saying that you should resubmit the post data?
If you use ‘window.location.reload(true)’ to reload your page, try doing something like ‘window.location = window.location;’ instead. This should refresh the page but not resubmitting it.
If you reload your page from a popup (‘window.opener.location.reload();’)you would use ‘window.opener.location.href = indow.opener.location.href;’
Possibly you could only refresh part of that page that could contain new data.
14.09.2008 at 07:09:59
Hi,
The problem exists in myfaces-1.1.6 as well, but the solution with stupid command link works. Note to use commandLink but not commandButton, which is useless.