Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like an OS can have various addresses, right? The second datatable should not have <code>{userOS.selectedOS}</code>as its value. Instead, it should point to a list of addresses that should be populated in your <code>onRowSelect()</code>method. Keep in mind that a datatable needs a value that is an object that is a collection of some sort in order to work. That is not the case with <code>{userOS.selectedOS}</code>.</p> <p>Here's what I'd do:</p> <ol> <li>Add a list of addresses to your bean and populate that list in your <code>onRowSelect()</code> method</li> <li>Create a getter for that list</li> <li>Make your second datatable point to that list;</li> <li>Remove <code>oncomplete="userDialog"</code>from your <code>p:ajax</code> tag (it will probably give you a javascript error unless you have a <code>p:remoteCommand</code> with that name somewhere)</li> <li>Although you should be able to update a datatable directly from <code>p:ajax</code>, I've had problems with that in the past so I normally just wrap a mine in a panel group and update the panel group instead. Give that I try if you're having issues.</li> </ol> <p>About your OS list (first datatable): never use getters to perform complex operations (like accessing the database). Those getters get executed many times during the JSF lifecycle and you don't want to repeat a bunch of queries to the database, right? Print something to the console in the beginning of the method <code>getOsList()</code> or put a breakpoint there if you don't believe me. You should declare a list in your bean and populate that list when appropriate. If you're using session scoped beans, you need to populate the list every time you navigate to that page. If you're using view/request scoped beans, the bean constructor would be a good place to populate the list.</p> <p><strong>EDIT</strong>:</p> <p>Add this to the form tag in your xhtml:</p> <pre><code>... &lt;h:form prependId="false"&gt; &lt;f:metadata&gt; &lt;f:event type="preRenderView" listener="#{userOS.populateOsList}" /&gt; &lt;/f:metadata&gt; ... </code></pre> <p>This will populate the OS list when you load the page. It's important to do this here since your bean is session scoped and loading the list in the constructor could introduce some problems.</p> <p>I refactored your bean code. Try this:</p> <pre><code>@ManagedBean(name = "userOS") @SessionScoped public class KisiInfoProcess implements Serializable { private static final long serialVersionUID = 1L; private static final Logger log = LoggerFactory .getLogger(KisiInfoProcess.class); private List&lt;OgrenimSureciBean&gt; osList; private List&lt;AddressBean&gt; adresList; private OgrenimSureciBean selectedOS; private AddressBean selectedAdres; public OgrenimSureciBean getSelectedOS() { return selectedOS; } public void setSelectedOS(OgrenimSureciBean selectedOS) { this.selectedOS = selectedOS; } public AddressBean getSelectedAdres() { return selectedAdres; } public void setSelectedAdres(AddressBean selectedAdres) { this.selectedAdres = selectedAdres; } public void setOsList(List&lt;OgrenimSureciBean&gt; osList) { this.osList = osList; } public List&lt;OgrenimSureciBean&gt; getOsList(){ return this.osList; } public void setAdresList(List&lt;AddressBean&gt; adresList) { this.adresList = adresList; } public List&lt;AdressBean&gt; getAdresList(){ return this.adresList; } public void onRowSelect(SelectEvent event) { try { populateAddresList((OgrenimSureciBean) event.getObject()); } catch (Exception e) { e.printStackTrace(); } } public void populateOsList() { OgrenimsureciDAO ogrenimsureciDAO = new OgrenimsureciDAO(); osList = new ArrayList&lt;OgrenimSureciBean&gt;(); for (Iterator i = ogrenimsureciDAO.findByMezunOgrenciler((short) 8) .iterator(); i.hasNext();) { Ogrenimsureci og = (Ogrenimsureci) i.next(); OgrenimSureciBean osBean = new OgrenimSureciBean(); osBean.setBolum(og.getBolum()); osBean.setAd(og.getKisiByKisiid().getAd()); osBean.setSoyad(og.getKisiByKisiid().getSoyad()); osBean.setAltbirim(og.getAltbirim()); osBean.setOgrencino(og.getOgrencino()); osBean.setKisiid(og.getKisiByKisiid().getKisiid()); osBean.setOgrencidurum(og.getOgrencidurum()); osList.add(osBean); System.out.println("osBean : " + osBean.toString()); } return osList; } public void populateAddresList(OgrenimSureciBean selected) throws Exception { log.debug("PersonalInfoProcess - getAddressInfo - Start"); adresList = new ArrayList&lt;AddressBean&gt;(); KisiDAO kisiDAO = new KisiDAO(); AdresDAO adresDAO = new AdresDAO(); Long kisiid = selected.getKisiid(); System.out.println("kisiid :" + kisiid); Kisi kisi = kisiDAO.findById(kisiid); for (Iterator i = kisi.getKisiadresis().iterator(); i.hasNext();) { Kisiadresi kisiAdresi = (Kisiadresi) i.next(); System.out.println("i :" + i); Adres tmpAdres = adresDAO.findById(kisiAdresi.getId().getAdresid()); if (tmpAdres != null) { AddressBean address = new AddressBean(kisiid); if (tmpAdres.getAdresturu() == null) { address.setAddressType(null); } else { address.setAddressType(tmpAdres.getAdresturu().getAd()); } address.setAddress(tmpAdres.getAdres()); if (tmpAdres.getIl() == null) { address.setCity(null); } else { address.setCity(tmpAdres.getIl().getAd()); } if (tmpAdres.getUlke() == null) { address.setCountry(null); } else { address.setCountry(tmpAdres.getUlke().getAd()); } adresList.add(address); System.out.println("adres" + address); System.out.println("adreslist" + adresList); } log.debug("PersonalInfoProcess - getAddressInfo - End / Returning"); } } } </code></pre> <p>Note that the populate methods do not return a list; they use the list declared on the bean itself. Those are the lists you'll point your page to.</p>
    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.
    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