oamSubmit.js is absent if f:ajax is used on a webpage

I've encountered a frustrating issue while using MyFaces that is really getting on my nerves. I have tried versions 2.2.10 and 2.2.12, along with PrimeFaces 6.0, although the latter may not be relevant.

Every time I add an f:ajax tag to a page, my commandLink stops working and I receive a JavaScript console error:

ReferenceError: myfaces is not defined

After some investigation, I discovered that the following line is not generated when there is an f:ajax tag present on the page:

<script type="text/javascript" src="/console/javax.faces.resource/oamSubmit.js.jsf?ln=org.apache.myfaces"></script>

To workaround this issue, I manually insert this script line by adding the following JavaScript right after the <head> tag:

<script>
if (!window.myfaces) {
  document.write(unescape('%3Cscript type="text/javascript" src="/console/javax.faces.resource/oamSubmit.js.jsf?ln=org.apache.myfaces"%3E%3C/script%3E'));
}
</script>

While this hack seems to resolve the problem, it leaves me feeling uneasy having to resort to such a workaround. Can anyone provide insight into what might be causing this issue?

Answer №1

Encountered the same problem myself. I came across an issue with Mojarra not being defined when javax.faces.PROJECT_STAGE is set to Production, along with another problem related to submitForm() not being defined for myfaces.JSF_JS_MODE 'minimal-modern'. After some research, I discovered that these issues only occur when javax.faces.PROJECT_STAGE is set to Production.

The solution that worked for me was adding the following code snippet to the web.xml file:

<context-param>
    <param-name>org.apache.myfaces.JSF_JS_MODE</param-name>
    <param-value>minimal</param-value>
</context-param>

This resolved the problem for me.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting Next.JS Fast Refresh failure on Windows with Ubuntu or WSL

When adjusting and saving files with reactJS/Next.JS, I encountered an issue where the server fails to recognize these alterations and update accordingly. I experimented with different settings based on various articles I came across, but unfortunately no ...

Executing JavaScript code sequentially

I've been running into an issue with my JavaScript code not executing in the expected order. It seems to be skipping straight to the if(!hadError) condition before handling any errors that may occur, resulting in hadError always being true. I understa ...

How to implement div scrolling on button click using Angular 4

Is there a way to make the contents of a div scroll to the left when one button is clicked and to the right when another button is clicked? I've tried using ScrollLeft, but it doesn't seem to be working... Here's the HTML code: <button ...

Can one window interact with the window that opened it?

I am developing an application that requires users to log in using their Reddit account. Once they accept, a new window called SpawnedWindow opens, prompting users to connect with Reddit. Upon successfully connecting, SpawnedWindow redirects to a specific ...

How do I incorporate global typings when adding type definitions to an npm module?

Suppose I create a node module called m. Later on, I decide to enhance it with Typescript typings. Luckily, the module only exports a single function, so the m.d.ts file is as follows: /// <reference path="./typings/globals/node/index.d.ts" /> decl ...

How to transfer identification from one AngularJS page to another

I need help figuring out how to retrieve an ID from the list.html page and use that same ID to display corresponding details on the list-detail.html page. I am new to using angularjs and struggling with getting the details based on the ID. Below is my code ...

Tips for displaying HTML5 validation messages when the input is changed

I am working on a form where I prefer not to submit it directly, as I am making an AJAX call instead. However, I still want the HTML5 validation messages to show up when an input field is left empty. I have managed to display the validation message when a ...

Guide on determining the total count based on a specific condition with the help of jQuery

Using AJAX, I have successfully retrieved all status values such as Active, ACTIVE_DRAFT, and Pending. However, I only want to select the statuses that are equal to ACTIVE. To do this, I am using an if condition which is working fine. After filtering by st ...

How can I use JavaScript to create a function that communicates with a PHP file to dynamically add keys and properties to a JSON file?

Currently employing Discord.JS for the creation of a Discord Bot, I am faced with a command: if(command === "addme") { //code here return message.reply(`Added ${message.author} to Database!`); }; I am looking to incorporate a PHP function from anothe ...

Modifying an object property by replacing it with a different value stored in the same object - JavaScript

Consider the object below: { id: 1, name: 'jdoe', currentDayHours: null, totalHours: [{ task: 'cleaning', hours: 10}, { task: 'reading', hours: 2 }]} A function is needed to update the currentDayHours based on the task param ...

Using JavascriptExecutor in Selenium to scroll through Bootstrap modal windows containing lengthy content

Is there a way to scroll through a modal window that uses Bootstrap's modal class? I typically use JavascriptExecutor with the window.scroll/scrollBy method, but encountered an issue when trying to do so with a modal containing lengthy content. The sc ...

Having trouble figuring out how to update a list using ajax in Yii

I need to modify a JavaScript function that filters the content of a list. The current code looks like this: var id = $(this).data('id'); $.fn.yiiListView.update('contests-list', { data: {category: 2} }); I couldn't find any ...

Guide on obtaining the file path of an uploaded file through the use of HTML, JavaScript, and PHP

After successfully uploading an image from my drive, I am encountering an issue where I am unable to locate the folder path of that image For example: C:\Images\Logo\Image.png $('#pngfile').change(function (e) { var tmppath = URL ...

Refresh the database values every five minutes

I am currently developing a web application that assigns users a ranking based on their activity on Twitter and on my website. For this reason, I want to update their rank every five minutes by retrieving their latest Twitter activity and updating it in m ...

What is the best method for transferring properties to the parent component using Vue router?

I have a multi-step form that each step has a different header structure. The only variation in the header among the steps is the wording, which changes as you progress through the steps. I am looking for a way to achieve this using Vue Router: pa ...

What is the best way to update the color of a label in a Mantine component?

When using the Mantine library, defining a checkbox is done like this: <Checkbox value="react" label="React"/> While it's possible to change the color of the checkbox itself, figuring out how to change the color of the label ...

Guide on transferring value from a <select> element using JavaScript

I'm attempting to pass the selected value of a <select> in the onChange function. I've explored this question on SO, but unfortunately, using this and this.value hasn't been successful. I understand that the question is quite old... se ...

Is the violation of separation of concerns evident in the implementation of custom security HTTP headers

Is it considered a best practice to use custom application specific, security related HTTP headers even though it may potentially violate the separation of concerns? I understand that utilizing a custom header to manage service behavior could tightly bind ...

Dispatch a post request from the client to node.js

As I dive into learning about node.js, I decided to create a simple guestbook application. This app consists of a comment form and a display of previous comments. Currently, the app operates solely on the client side with items being stored in local storag ...

Having issues with the background-image style not displaying correctly in the header of an

Trying to update the "background-image:" of a CSS class upon button click. JQuery: $(function() { $('button').on('click', function() { $('.masthead2').css('background-image', 'url("../img/whitehead ...