oamSetHiddenInput is not defined – temporarily solution

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>

Advertisements

5 Responses to “oamSetHiddenInput is not defined – temporarily solution”

  1. hem Says:

    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.

  2. Marteyn Says:

    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);
    //*****************************************************************************

    }

  3. roneiv Says:

    Marteyn, that’s a good workaround I hadn’t thought about 🙂 But still, very nice and simple. Thank you for sharing!

  4. roneiv Says:

    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.

  5. Dmitry Says:

    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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: