p:selectOneMenu selection does not reset after refresh.

UI Components for JSF
Post Reply
KingdomHeart
Posts: 280
Joined: 25 Jun 2010, 01:18

12 Jan 2012, 16:52

This happen only on Firefox, that when I make an selection on p:selectOneMenu, then refresh the page, the selection does not go away. Here is small piece of code to replicate

Code: Select all

<h:form id="myForm">
            <p:selectOneMenu value="#{viewBean.selectedFood}">
                <f:selectItem itemLabel="Select One" itemValue=""/>
                <f:selectItems value="#{viewBean.foodList}"/>
                <p:ajax update=":myForm:text"/>
            </p:selectOneMenu>
            <br/>
            <h:outputText id="text" value="#{viewBean.selectedFood}"/>
</h:form>

Code: Select all

@ManagedBean
@ViewScoped
public class ViewBean implements Serializable {
    
    private List<String> foodList;
    private String selectedFood;

    public ViewBean() {
    }

    @PostConstruct
    public void init() {

        foodList = new ArrayList<String>();
        foodList.add("Pizza");
        foodList.add("Pasta");
        foodList.add("Hamburger");
    }
    //setter, getter
}
This can also replicated via SHOWCASE, go to http://www.primefaces.org/showcase-labs ... neMenu.jsf using Firefox, make a selection on any of the dropbox, and refresh, the selection is still there. If using chrome or IE, this does not happen

Mojarra 2.1.10, Glassfish 3.1, Tomcat 7, Primeface 3.3.1
IE 6-8, FireFox 10-13
MAC OSX Lion, Windows XP, 7

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Jan 2012, 17:08

Please file an issue so we can check.

breilly
Posts: 8
Joined: 09 Jan 2012, 15:58

12 Jan 2012, 17:22

Unlike the problem described in viewtopic.php?f=3&t=17425, this is OK for p:selectOneMenu.

The problem with the selection model of p:dataTable was that what the user saw after reload in Firefox was different than what was stored in the hidden input. The two ways to solve that are to reset the selection model (or prevent Firefox from trying to be helpful, which is what autocomplete="off" does) or to read the value of the hidden input after loading and update the display to reflect the selection (though I suspect this could be a little tricky to implement).

The fact that you can easily see Firefox's "helpful" behavior in the showcase means that it isn't a real problem in practice. What the user sees is what will be submitted. It behaves exactly the same as any form would in Firefox, which you can observe with even a static HTML file:

Code: Select all

<form>
  <select>
    <option></option>
    <option>one</option>
    <option>two</option>
    <option>three</option>
  </select>
</form>
PrimeFaces 3.4.1, Mojarra 2.1.7, JBoss AS 7.1.1

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Jan 2012, 17:24

Also please test with h:selectOneMenu to compare the behavior. If it is same, we'll take no action.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Jan 2012, 17:27

I've tested this on webkit and firefox and I agree with breilly, this is not an issue but browser behavior.

p:selectOneMenu wraps a select tag and resolves the initial value to display from the wrapped select tag so behavior is correct.

KingdomHeart
Posts: 280
Joined: 25 Jun 2010, 01:18

12 Jan 2012, 17:27


Mojarra 2.1.10, Glassfish 3.1, Tomcat 7, Primeface 3.3.1
IE 6-8, FireFox 10-13
MAC OSX Lion, Windows XP, 7

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Jan 2012, 17:28

I've marked the issue as WontFix, see two posts above.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 85 guests