Note that there are some explanatory texts on larger screens.

plurals
  1. POIceFaces duplicate entries in combos, menus after layout change
    text
    copied!<p>My IceFaces 1.8 based application starts with a very simple xhtml that includes a different one based on a bean's property. This property is bound to a combo's item that is included in every page. If the user selects a layout from this combo, the page updates to the new layout.</p> <p>It is all ok, except that after every single page layout change, the items in the layout selector combo get duplicated, triplicated and so on.</p> <p>This is the "multiplexer" xhtml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ice="http://www.icesoft.com/icefaces/component"&gt; &lt;ui:include src="#{system.layout}"&gt; &lt;/ui:include&gt; &lt;/html&gt; </code></pre> <p>And this is the layout selector that is included into every layout xhtml:</p> <pre><code> &lt;ice:form id="layoutSelectForm"&gt; &lt;ice:outputLabel for="layoutSelector"&gt;#{msgs['LayoutSelect.Label']}: &lt;/ice:outputLabel&gt; &lt;ice:selectOneMenu id="layoutSelector" binding="#{layoutSelect.som}" value="#{layoutSelect.selectedLayout}" valueChangeListener="#{layoutSelect.processValueChange}" partialSubmit="true"&gt; &lt;f:selectItems value="#{layoutSelect.allLayouts}" /&gt; &lt;/ice:selectOneMenu &gt; &lt;/ice:form&gt; </code></pre> <p>Here is the code of the LayoutSelect backing bean:</p> <pre><code>public class JSFLayoutSelect implements InitializingBean, ValueChangeListener { private EventManager eventManager; private String mainApplFrmURL; private HtmlSelectOneMenu som; public List&lt;SelectItem&gt; allLayouts; private String selectedLayout; @Override public void processValueChange(ValueChangeEvent event) throws AbortProcessingException { eventManager.publish("layout-select/change", event.getNewValue()); logger.info("Layout changed event occured: " + event.getNewValue()); try { FacesContext.getCurrentInstance().getExternalContext().redirect(mainApplFrmURL); } catch (IOException e) { logger.error(e.getMessage()); } } @Override public void afterPropertiesSet() throws Exception { allLayouts = new ArrayList&lt;SelectItem&gt;(); allLayouts.add(new SelectItem("dev", "Core Dev")); allLayouts.add(new SelectItem("classic", "Core Classic")); allLayouts.add(new SelectItem("modern", "Core Modern")); selectedLayout = "dev"; } public List&lt;SelectItem&gt; getAllLayouts() { return allLayouts; } public String getSelectedLayout() { return selectedLayout; } /* some unimportant methods are not here */ } &lt;bean name="layoutSelect" class="hu.hgap.comp.impl.JSFLayoutSelect" scope="session"&gt; &lt;property name="eventManager" ref="SessionEventManager"/&gt; &lt;property name="mainApplFrmURL" value="/ICEFacesSpringDemoV2/secured/ApplFrm.faces" /&gt; &lt;/bean&gt; </code></pre> <p>Can you tell me what shall I do to avoid duplicating combo entries? I see that after changing the layout the very same combo gets rendered again and the combo items are pushed into it again from the server.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload