java - Data is getting displayed on the UI -


iam learing jsf ejb3.0 + jpa(hibernate)

iam getting data tables on screen not displaying anything. here code.
managed bean

package retail.web.mbean;  import java.sql.timestamp; import java.util.calendar; import java.util.date; import java.util.hashmap; import java.util.list; import java.util.map; import java.util.map.entry; import java.util.properties;  import javax.faces.bean.managedbean; import javax.faces.event.ajaxbehaviorevent; import javax.naming.initialcontext; import javax.naming.namingexception;  import retail.ejb.service.ordersessionbeanremote; import retail.model.vo.customer; import retail.model.vo.order; import retail.model.vo.products;  @managedbean public class ordersmb {      private order order = new order();      private hashmap<integer,string> customermap = new hashmap<integer,string>();      private hashmap<integer,string> productsmap = new hashmap<integer,string>();      private string customername;      private string productname;      private list<order> orderlist;      public order getorder() {         return order;     }      public void setorder(order order) {         this.order = order;     }       public hashmap<integer, string> getcustomermap() {         return customermap;     }      public void setcustomermap(hashmap<integer, string> customermap) {         this.customermap = customermap;     }      public hashmap<integer,string> getproductsmap() {         return productsmap;     }      public void setproductsmap(hashmap<integer, string> productsmap) {         this.productsmap = productsmap;     }      public string getcustomername() {         return customername;     }      public void setcustomername(string customername) {         this.customername = customername;     }        public string getproductname() {         return productname;     }      public void setproductname(string productname) {         this.productname = productname;     }      public list<order> getorderlist() {         return orderlist;     }      public void setorderlist(list<order> orderlist) {         this.orderlist = orderlist;     }      public void getorderlists() throws namingexception{         properties p = new properties();         //p.put("java.naming.factory.initial","com.sun.jndi.cosnaming.cnctxfactory");         p.setproperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.serialinitcontextfactory");         p.setproperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");         p.setproperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.jndistatefactoryimpl");         p.setproperty("org.omg.corba.orbinitialhost", "localhost");         p.setproperty("org.omg.corba.orbinitialport", "3700"); //any configured port different 3700 - 34513         initialcontext c = new initialcontext(p);         ordersessionbeanremote remote = (ordersessionbeanremote) c.lookup("java:global/retailproducts/ordersessionbeanimpl!retail.ejb.service.ordersessionbeanremote");          list<order> orderlist = remote.getorderlists();          setorderlist(orderlist);       } public void deleteorder(order order) throws namingexception{     properties p = new properties();     //p.put("java.naming.factory.initial","com.sun.jndi.cosnaming.cnctxfactory");     p.setproperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.serialinitcontextfactory");     p.setproperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");     p.setproperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.jndistatefactoryimpl");     p.setproperty("org.omg.corba.orbinitialhost", "localhost");     p.setproperty("org.omg.corba.orbinitialport", "3700"); //any configured port different 3700 - 34513     initialcontext c = new initialcontext(p);     ordersessionbeanremote remote = (ordersessionbeanremote) c.lookup("java:global/retailproducts/ordersessionbeanimpl!retail.ejb.service.ordersessionbeanremote");     remote.deleteorder(order); }  } 


xhtml page

<?xml version="1.0" encoding="iso-8859-1" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"         xmlns:h="http://java.sun.com/jsf/html"       xmlns:ui="http://java.sun.com/jsf/facelets"       xmlns:c="http://java.sun.com/jsp/jstl/core"       xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>list of orders</title>      <script>         window.onload = function() {             document.getelementbyid('hidden:link').onclick();         }     </script>         <h:outputstylesheet library="css" name="table-style.css"  />     </h:head>     <h:body>    <h:form id="hidden" style="display:none">         <h:commandlink id="link">         <f:ajax event="click" listener="#{order.getorderlists}"/>          </h:commandlink>     </h:form>         <h1 style="background-color:#4863a0;color:white;">list of orders</h1>         <f:view>  <h:form>         <table class="order-table">             <tr>                 <th class="order-table-header">order #</th>                 <th class="order-table-header">customer</th>                 <th class="order-table-header">item</th>                 <th class="order-table-header">action</th>             </tr>             <tbody>                 <ui:repeat var="o" value="#{order.orderlist}" >                    <tr>                         <td class="order-table-even-row">#{o.orderid}</td>                         <td class="order-table-even-row">#{o.customername}</td>                         <td class="order-table-even-row">#{o.producttile}</td>                         <td class="order-table-even-row"><h:commandlink value="delete" action="#{order.deleteorder(o)}" /></td>                        </tr>                  </ui:repeat>             </tbody>         </table>         </h:form>         <table >  <tr><td>total customers: 1</td> </tr> </table> <div style=" border-bottom: 5px ridge blue;"> </div>   <table> <tr> <td><h:outputlink  value="createbook.xhtml">create new order</h:outputlink>|</td><td><h:outputlink  value="ebusiness.jsp">main page</h:outputlink></td> </tr> </table> </f:view>     </h:body> </html> 

the problem you're not loading list content anywhere. best place doing in @postconstruct on managed bean. also, since invoke ajax calls on page, better if set scope of managed bean @ least @viewscoped:

@managedbean @viewscoped public class ordersmb {     //attributes, methods, getters, setters...     @postconstruct     public void init() {         try {             getorderlists();         } catch (namingexception ne) {             //handle error here...         }     } } 

in case want load data using ajax call (as looks want/need), forgot update component display data. can achieve using render attribute of <f:ajax>. in case, must provide full id of component since you're updating component outside form.

<h:form id="hidden" style="display:none">     <h:commandlink id="link">     <f:ajax event="click" listener="#{order.getorderlists}"         render=":frmdata" />     </h:commandlink> </h:form> <!-- html/jsf content here... --> <h:form id="frmdata"> </h:form> 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -