0

Here is a very simple jsf page:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <h:form enctype="multipart/form-data">
        Hello<br/>
        <h:outputText  value="#{backingBean.currentTime}" />
        <br/>
        <h:outputText id="contatoreID" value="#{backingBean.counter}" />
        <br/>
            <h:commandButton value="Add" action="#{backingBean.add}">
                <f:ajax render="contatoreID"/>
            </h:commandButton>
            <br/>
            <hr/>
            <h:commandButton value="Reset Counter" action="#{backingBean.resetCounter}" />
    </h:form>

</h:body>
</html>

The backing bean implementation is trivial.

It has a form with multipart/form-data and two buttons, one with ajax behavior which refresh only one component in the page and a 'standard' submit button. If the Add button is pressed then Reset Counter doesn't cause the browser to refresh or navigate to a new page.

After lots of searches on internet I found this related bug report:The combination of enctype="multipart/form-data" and ajax stops navigation in some scenarios but it is not clear to me if it is recognized as a real bug or a misconfiguration issue. I'm using latest available Mojarra release 2.2.5. I cannot seen any progress on this bug report. Can you suggest some workaround ?

Besides I recently moved a web application from Glassfish 3.1.2 to Glassfish 4.0. It worked well before while now I'm struggling with lots of problems which seem bug related, such as this on <ui:repeat>.

I'm conscious I cannot ask opinion related questions here, but I'm wondering if I'm the only person which is having a bad experience with JSF 2.2 release. Maybe I was using Jsf 2.0 in a wrong/unsafe manner...

UPDATE

I add the backing bean code

@ManagedBean
@SessionScoped
public class BackingBean {

/**
 * Creates a new instance of BackingBean
 */
public BackingBean() {
}

int counter = 0;

public int getCounter() {
    return counter;
}

public void setCounter(int counter) {
    this.counter = counter;
}

public void add() 
{
    counter++;
    System.out.println("add called " + counter);
}

public void azzera()
{
    counter =0;
    System.out.println("Azzera ");
}

public String getOra() { return new Date().toString();}
}
Community
  • 1
  • 1
Filippo
  • 1,123
  • 1
  • 11
  • 28
  • Just for curiosity, does it work when your remove the `enctype` attribute from the form tag? Multipart is recommended to be used only with file upload components (as it is far more complex enconding). For this trivial form you definitelly don't need it. Could it be a Mojarra bug? It could, but unless you post some complete test case, including the managed bean, we will not be able to test it. – Aritz Mar 08 '14 at 13:13
  • It works removing enctype. The behaviour was observed in a page with file upload and then a very simple test page was created. As already stated the backing bean implementation is trivial. Just use a sessionScope bean, expose current time and counter, add -> counter++, resetCounter -> counter = 0. – Filippo Mar 10 '14 at 09:23
  • As it is trivial, wouldn't be better just to post it and let the whole [SSCCE](http://www.sscce.org/) available? In order to let SO users copy/paste and test it. Keep in mind you'll need it if you want to open an issue report for Mojarra too. – Aritz Mar 10 '14 at 09:37
  • Yesterday I answered a question which was GlassFish 4 - JSF related. Apparently, the JSF implementation shipped by default with the server has some critical bugs. Have a look: http://stackoverflow.com/a/22329026/1199132 – Aritz Mar 12 '14 at 10:30
  • As stated previously I'm using latest available Mojarra release 2.2.5, not 2.2.0 which ships with Glassfish. Maybe this time they released too early... and now they are fixing bugs with new bugs.. – Filippo Mar 12 '14 at 11:33
  • Yep, sorry about that :-( I'll give it a try later in Tomcat 7 – Aritz Mar 12 '14 at 11:34
  • Just read the BalusC answer here:[link](http://stackoverflow.com/questions/18517384/fviewparam-doesnt-pass-required-parameter-when-new-xmlns-jcp-org-namespace-is) : My conclusion is that I switched to Glassfish 4.0 too early. – Filippo Mar 12 '14 at 11:45
  • Could be. Personally, I prefer a bit more mature versions to switch to, specially if you don't have special reasons to perform the upgrade. It also depends on the software: Java 8.0.0 would probably be more consistent than Mojarra 2.2.0 for example, as it has thousands of people behind it and candidate releases had been published since 2012. The same happens with GF 4.0, you should need a real reason to switch to it cause drawbacks could be wider than benefits. – Aritz Mar 12 '14 at 11:53

0 Answers0