Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The first ajax call sets the view's parameters while subsequent ones do not. #4714

Closed
bzurmaar opened this issue May 29, 2020 · 4 comments
Closed
Labels

Comments

@bzurmaar
Copy link

As the issue's title already tells the first ajax call set's the view parameters while subsequent requests do not. The problem is easily reproducible. I'm using Wildfly 19.0 which includes Mojarra 2.3.9.SP06 in my test setup.

I have the following bean:

package test;

import java.io.Serializable;

import javax.faces.view.ViewScoped;
import javax.inject.Named;

@Named
@ViewScoped
public class TestController implements Serializable {

    private static final long serialVersionUID = 1L;

    String param;

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        System.out.println("param set to " + param);
        this.param = param;
    }
}

I also have simple .xhtml page which contains one button that fires an ajax request:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">

<h:head></h:head>

<f:metadata>
    <f:viewParam id="param" name="param" value="#{testController.param}"/>
</f:metadata>

<h:form id="form">
  <h:commandButton id="button" value="Test">
    <f:ajax execute="@this"></f:ajax>
  </h:commandButton>
</h:form>

</html>

You can expose the bug now by opening https://localhost:8443/test/test.xhtml?param=foo in your browser. As expected the log claims that the view parameter was set to "foo". Now when you first press the button the log again claims that param was set to "foo" proving that the setter was called again. This is unexpected and should not happen from my point of view. It's even more puzzling, that every subsequent button press does not cause the setter to called again. Even stranger the first and all subsequent calls look exactly alike but cause different behavior on the server side.

My expectation was that view parameters never get set by ajax calls because the forms action url does not contain the view parameters. I could also live with ajax calls always setting the view's parameters again. Having the first ajax call behave differently than the subsequent ones is irritating to say the least.

See also this stackoverflow question for a discussion about the issue.

@erickdeoliveiraleal
Copy link

I think it's related to #4550. It was fixed, but 2.3.15 is not released yet with this long awaited fix. Wildfly 20.0.1 already incorporated this fix.

@erickdeoliveiraleal
Copy link

Looks like issue is stil really there. #4734

@bzurmaar
Copy link
Author

Sorry for the long delay. I can confirm the bug is still present in wildfly 20.0.1, i.e. Mojarra 2.3.9.SP11.

@BalusC
Copy link
Contributor

BalusC commented Feb 20, 2022

Fixed in 2.3.15 via #4734

@BalusC BalusC closed this as completed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants