Note that there are some explanatory texts on larger screens.

plurals
  1. POprimefaces how to retrieve changed values from picklist
    primarykey
    data
    text
    <p>i have implemented the following picklist:</p> <pre><code>&lt;p:pickList id="pickList" value="#{reportConfiguratorBean.dualListVars}" var="cRVariable" itemValue="#{cRVariable}" itemLabel="#{cRVariable.varName}" converter="#{cRImageTypeConverter}" immediate="true" rendered="true" &gt; &lt;f:facet name="sourceCaption"&gt;Available Variables&lt;/f:facet&gt; &lt;f:facet name="targetCaption"&gt;Associated Variables&lt;/f:facet&gt; &lt;/p:pickList&gt; &lt;f:facet name="footer"&gt; &lt;p:commandButton id='varassociate' action="#{reportConfiguratorBean.setAssocImTypVariables()}" value='Associate' process="@this,pickList" /&gt; &lt;/f:facet&gt; </code></pre> <p>Picklist is populated correctly (using getAssocImTypVariables() from database). But my <strong>ISSUE</strong> is that <strong>i can not capture the changed picklist values</strong> of a user alters the source and target lists. I am trying to capture the changes using a commandButton method "setAssocImTypVariables" as follows:</p> <pre><code>public void setAssocImTypVariables() { System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; entered"); List&lt;CRVariable&gt; sourceVariables = this.dualListVars.getSource(); List&lt;CRVariable&gt; targetVariables = this.dualListVars.getTarget(); System.out.println(dualListVars.getSource()); System.out.println(dualListVars.getTarget()); for (CRVariable sourceVariable:sourceVariables) { System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I am a source variable: " + sourceVariable.getVarName()); } for (CRVariable targetVariable:targetVariables) { System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I am a target variable: " + targetVariable.getVarName()); } } </code></pre> <p>So if for example i have a picklist with INITIAL source = (Obj1,Obj2,Obj3,Obj5,Obj7) and target = (Obj4,Obj6), i move "Obj1" from source to target BUT in my console i get: </p> <p>--------- entered [] []</p> <p>So my dualListVars (source and target) is not populated! I have two empty lists for source and target...</p> <p><strong>So my method CAN NOT perceive picklist's changes... Any ideas? I am new to java + primefaces so it could be something really fundamental :(</strong></p> <p>I am also attaching the method getAssocImTypesOnLoad():</p> <pre><code>public void getAssocImTypesOnLoad() { Long imTypeId = Long.parseLong(virtualId); List&lt;CRVariable&gt; source; List&lt;CRVariable&gt; target; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null; try { tx = session.beginTransaction(); String hq3 = "select distinct v from CRVariable v join v.crimagetypes t where t.id in (:itid)"; Query query3 = session.createQuery(hq3); query3.setParameter("itid",imTypeId); target = query3.list(); String hq4 = "select v FROM CRVariable v WHERE v.id not in (" + "select distinct v1.id " + "from CRVariable v1 " + "join v1.crimagetypes t2 " + "where t2.id in (:itid))"; Query query4 = session.createQuery(hq4); query4.setParameter("itid",imTypeId); source = query4.list(); dualListVars = new DualListModel&lt;CRVariable&gt;(source, target); tx.commit(); } catch (Exception e) { if (tx != null) { e.printStackTrace(); } } finally { session.close(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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