Jmeter and JSF, managed bean method on commandLink action not invoked
Asked Answered
M

0

6

I'm trying to stress a rather simple JSF web application, that uses authentication, jMeter never invokes an action method (in a managed bean) associated with a pressed button. The authentication with multiple users (loaded from a CSV file) works perfectly (or so I think). I reduced the test plan to the bare minimum, in order to try a debug this situation. I have a login, and a simple page with a commandLink whose action is a method in a ManagedBean (with requestScope).

My xpath extractor value is: //input[@id='javax.faces.ViewState']/@value

I also tried with a regex extractor, using the expression id=\"javax.faces.ViewState\" value=\"(.+?)\With any of them, it seems to work fine (I used to have some viewState related problems.

On he POST request (that contains the javax.faces.ViewState) I have ${jsfViewState} as the value (jsfViewState is an user defined variable that holds the viewState saved from the previous GET method).

The page with the commandLink is (note that I hardcoded the value on purpose, to more easily identify the problem):

<h:body>
    <ui:composition template="/template/template.xhtml">
        <ui:define name="content">
            <c:set value="Category" target="#{menu}" property="title"/>
            <ui:repeat value="#{category.list}" var="cat">
                <h:form id="categoryForm">
                    <h:commandLink id="btnOrd" action="#{product.placeOrder(1)}">COMPRAR</h:commandLink>
                </h:form>
                <br/>
            </ui:repeat>

        </ui:define>
    </ui:composition>
</h:body>

The managedBean:

@Named("product")
@RequestScoped
public class ProductMBean {

    @Inject
    private ProductEBean productEBean;
    @Inject
    private UserProductEBean userProductEBean;

    public List<Product> getList(){
        return productEBean.findAll();
    }

    private void addMessage(FacesMessage message){
        FacesContext.getCurrentInstance().addMessage(null, message);
    }

    public String placeOrder(long id){
        userProductEBean.createNewOrder(id);
        Product product = productEBean.findById(id);
        addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Your order of " + product.getName() + "has been processed. Thank you for using our service.", null));
        return "success";
    }

No new order is created (although it works perfectly if I do it manually). Different invokations of commandLink (for page navigation using function parameters, for example) are working, and jMeter navigate trough the pages.

The parameters passed to the POST request aside from the ViewState are:

**Name**                                  **Value**
j_idt${nb.rampup}6:0:categoryForm         j_idt${nb.rampup}6:0:categoryForm
j_idt${nb.rampup}6:0:categoryForm:btnOrd  j_idt${nb.rampup}6:0:categoryForm:btnOrd

And on jMeter:

The request
POST http://localhost:8080/easuy-war/easuy/categories/list.xhtml

POST data:
j_idt26%3A0%3AcategoryForm=j_idt26%3A0%3AcategoryForm&javax.faces.ViewState=&j_idt26%3A0%3AcategoryForm%3AbtnOrd=j_idt26%3A0%3AcategoryForm%3AbtnOrd

Cookie Data:
$Version=0; JSESSIONID=f24cb939085c6bc761efdc76f67b; $Path=/easuy-war

Relevant info on browser:

<form id="j_idt13" name="j_idt13" method="post" action="/easuy-war/easuy/categories/list.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt13" value="j_idt13" />
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="-9105321245957774265:-3870715546023364251" autocomplete="off" />
</form>

Thank you in advance.

Martinson answered 3/6, 2014 at 0:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.