How can I refresh entities in the following case.

I have a page that contains:
<div class="entry">
  |                             <a4j:log hotkey="M" />
  |                             <a4j:commandButton value="Reload" 
reRender="Sensor"/>
  |                             <div class="label">Sensor:</div>
  |                             <div class="input">
  |                                     <a4j:region renderRegionOnly="false">
  |                                             <h:selectOneMenu id="Sensor" 
value="#{messkette.sensor}"
  |                                                     
converter="#{selectItemHelfer}" required="true" disabled="#{gesperrt}">
  |                                                     <f:selectItems 
value="#{messketteEditor.alleSensorenMitBlank}" />
  |                                                     <a4j:support 
event="onchange" reRender="Funktion, Sensormessbereich, Einheit, Sensorwarnung" 
/>
  |                                             </h:selectOneMenu>
  |                                     </a4j:region>
  |                                     <h:message for="Sensor" 
styleClass="message" />
  |                                     <div><h:outputText id="Sensorwarnung" 
value="#{messketteEditor.sensorWarnung}" styleClass="kursiv" /></div>
  |                             </div>          
  |                     </div

Sometimes I need to edit or create a entry from database in a second instance 
of web browser. So the list in messketteEditor has changed. But when I perform 
the Reload commandButton the outcome is the same with no changes. 
What I have to do tell the Entitymanger to refresh the list from database.

Here the function that will be executet when a entity is changed or created
public String speichern() {
  |             
  |             checkKorrekterAufruf();
  |             
  |             if (!vorSpeichern()) {
  |                     ejbCtx.setRollbackOnly();
  |                     return null;
  |             }
  |             
  |             try {
  |                     
  |                     String message = "";
  |                     
  |                     T entity = getEntity();
  |     
  |                     if (neu) {
  |                             //Neues Entity, anlegen
  |                             em.persist(entity);
  |                             message = angelegtMessage();
  |                             loggeAenderung(getEntity(), "angelegt");
  |                     } else {
  |                             //Bestehendes Entity, Änderungen übernehmen
  |                             setEntity(em.merge(entity));
  |                             message = bearbeitetMessage();
  |                             loggeAenderung(getEntity(), "bearbeitet");
  |                     }
  |                     
  |                     nachSpeichern();System.out.println(entity);
  |                     
  |                     em.flush();
  |                                             
  |                     addMessage(message);
  |                                             
  |             } catch (Exception ex) {                        
  |                     ejbCtx.setRollbackOnly();
  |                     addWarning(speichernError() + " " + exceptionListe(ex));
  |                     System.out.println(ex.getMessage());
  |                     ex.printStackTrace();
  |                     
  |                     return null;
  |             }
  |             
  |             return zurueckOutcome; 
  |     }

and this is the code to return the list
private List<StandardEntity> listeHolen(Class<? extends StandardEntity> klasse, 
String where, String order) {
  | 
  |             String klassenName = klasse.getName();
  |             
  |             String query = "from " + klassenName;
  |             if (where != null)
  |                     query += " where " + where;
  |             if (order != null)
  |                     query += " order by " + order;
  | 
  |             List<StandardEntity> liste;
  |             
  |             try {
  |                     liste = (List<StandardEntity>) 
em.createQuery(query).getResultList();
  |             } catch (Exception ex) {
  |                     //Im Fehlerfall (z.B. nichts gefunden) leere Liste 
erzeugen
  |                     ex.printStackTrace();
  |                     liste = new Vector<StandardEntity>();
  |             }
  |             
  |             return liste;
  |     }

Is there a solution for this case?


Thanks
andi

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000915#4000915

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000915

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to