Thursday, November 11, 2021

Free Templates Source Code Simple Project Java ZK Framework


 

Free Templates Source Code Simple Project Java ZK Framework 

ZK Framework aims to combine the simplicity and security from its server-centric architecture, and the beauty and dynamics from the evolving client-side technologies.

The shadow components can easily turn Bootstrap templates and off-the-shelf HTML pages into dynamic web pages with MVVM data binding in Java. Data-handler and client-side command binding makes it extremely easy to integrate and reuse any 3rd party Javascript widgets or libraries in the most beloved Java way, while allowing you to still enjoy the equally important server-side integration and security.

To get this framework you can test the zkoss.org site or through the GitHub site on Search Type Zkoss-demo.


1. Download for sample : https://github.com/zkoss-demo  

    There are many templates that you can choose.

  • Choose ui-examples
 
 

2.  Open eclipse and import project ui-examples 
     (location extract file : D:\QRNOTES3\appk-project)
  • Klik File.. choose.. Import.. choose.. Exiting Maven Project
         You can read the previous article about Eclipse on this blog.


  • Root Directory : (location extract file : D:\QRNOTES3\appk-project)


  •  Finish import.. Test Running Project..  (http://localhost:8080/ui-examples/applications2/index.zul)
  • If successful it will appear like this, you can also see this tutorial through Youtube Channel with the link below.
  



Thank you for reading this article, I hope this article can help you. continue to  support this blog by sharing it with others. Hope it is useful.

  • Channel Youtube : 
In this YouTube video you will explain how step by step to get a free zk framework template and how it is in Eclipse as the tools.

 



 
D. Note (step by step learn java zk framework)


E. Reference :

Monday, October 18, 2021

Tutorial Java Web ZK Framework - Form Entry Part2 (Entry - Edit - Delete) Grid - Simple For Beginners #java

 

 
 
Tutorial Java Web ZK Framework - Form Entry Part2 (Entry - Edit - Delete) Grid
 
 

 

Create a simple form with simple code, and you can do it without having to have too complicated logic. :)

Here we try to help you understand that making an application is easy and does not need complicated steps.
 
 
A.  Form Design Customer.zul
 
<window id="win_customer" title="ENTRY CUSTOMER" 
border="normal" width="100%" use="com.apps.customer">

<grid height="150px" width="100%">
  <columns>
    <column width="30%"></column>
    <column width="70%"></column>
  </columns>
    <rows>
        <row>
            <label value="ID CUSTOMER"></label>
            <textbox id="idcust" width="100px"></textbox>
        </row>
        <row>
            <label value="NAME CUSTOMER"></label>
            <textbox id="namecust" width="100px"></textbox>
        </row>
        <row>
            <label value="ADDRESS"></label>
            <textbox id="address" width="100px"></textbox>
        </row>
        <row>
            <label value=""></label>
            <hbox>
            <button id="entry" label="ENTRY" onClick="win_customer.cleartext()"></button>
            <button id="save"  label="SAVE"  onClick="win_customer.saveitem(idcust.getValue(),namecust.getValue(),address.getValue())"></button>
            </hbox>
        </row>
    </rows>
</grid>

<listbox id="lstData" width="100%"  emptyMessage="No Items Match Your
  Search" onCreate="win_customer.viewlist()">
    <listhead>
        <listheader label="ID CUSTOMER" width="min"></listheader>   
        <listheader label="NAME CUSTOMER" width="400px"></listheader>   
        <listheader label="ADDRESS CUSTOMER" width="min"></listheader>   
        <listheader label="EDIT" width="100px"></listheader>   
        <listheader label="DELETE" width="100px"></listheader>   
    </listhead>
    </listbox>
  </window> 

B. Code Customer.java
 
package com.apps;

import com.apps.db.DBSQLConnection;
import com.google.common.util.concurrent.ExecutionError;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import org.zkoss.zul.*;
import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.Sessions;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;

public class customer extends Window {
    String SQL;     
    private String actionType="Entry";
    public void saveitem(String cid, String cname, String caddress) throws Exception {
       Connection Conn = new DBSQLConnection().openConnection(); 
        if (actionType.equals("Edit")) {
             SQL="UPDATE CUSTOMER SET namecust=?, address=? WHERE IDCUST=? ";
		}else {       
			SQL="INSERT INTO  CUSTOMER (NAMECUST,ADDRESS,IDCUST) VALUES (?,?,?)";
		}
        PreparedStatement prep = Conn.prepareStatement(SQL);
        prep.setString(1, cname);
        prep.setString(2, caddress);
        prep.setString(3, cid);
        prep.executeUpdate();
        Conn.close();  
       
     Messagebox.show("Data has been saved successfully..","Data Saved",Messagebox.OK,Messagebox.INFORMATION);   
              
     viewlist();        
  
    }
    
    public void viewlist() throws Exception { 
        Listbox lb=(Listbox)this.getFellow("lstData");
        lb.getItems().clear();             
        SQL="SELECT * FROM CUSTOMER";
        Connection Conn = new DBSQLConnection().openConnection();
        Statement st = Conn.createStatement();  
        ResultSet rs = st.executeQuery(SQL);
  
        while (rs.next()){  
             Listitem li = new Listitem();           
             final String cidcust=rs.getString("idcust"); 
			
			/*CREATE BUTTON EDIT IN GRID*/  
             Button btn = new Button();  
             btn.setLabel("EDIT");  
             btn.setWidth("60px");  
             btn.setHeight("25px");
             btn.setIconSclass("z-icon-file-o");           
             btn.addEventListener(Events.ON_CLICK, new
             org.zkoss.zk.ui.event.EventListener() {
				@Override  
                public void onEvent(Event event) throws Exception { 
                    EditView(cidcust)
                }           
            });
            Listcell lc = new Listcell();
            lc.appendChild(btn);
            /*CREATE BUTTON DELETE IN GRID*/
             Button btndel = new Button();
             btndel.setLabel("DELETE");
             btndel.setWidth("80px");
             btndel.setHeight("25px");  
             btndel.setIconSclass("z-icon-file-o"); 
             btndel.addEventListener(Events.ON_CLICK, new
             org.zkoss.zk.ui.event.EventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					DeleteView(cidcust);
                }           
            });
       
            Listcell lcdel = new Listcell();
            lcdel.appendChild(btndel);
            li.setValue(rs.getString("idcust"));
            li.appendChild(new Listcell(rs.getString("idcust")));
            li.appendChild(new Listcell(rs.getString("namecust")));
            li.appendChild(new Listcell(rs.getString("address")));
            li.appendChild(lc);
            li.appendChild(lcdel);
            lb.appendChild(li);
        }
        rs.close();
        st.close();
        Conn.close();
    }
  
     
    public void rptcustomer() throws Exception {
        Connection Conn = new DBSQLConnection().openConnection();
        Statement st = Conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM CUSTOMER");
        Map param = new HashMap();
        String namafile="customerlist";

        String reportSrc  = Sessions.getCurrent().getWebApp().getRealPath("content/rpt/rptcustomer.jasper");
        String reportDest = Sessions.getCurrent().getWebApp().getRealPath("content/rpt/"+namafile);
        
        JRResultSetDataSource jasperReports = new JRResultSetDataSource(rs);
        JasperPrint print = JasperFillManager.fillReport(reportSrc,param,jasperReports);     
        JasperExportManager.exportReportToPdfFile(print, reportDest);
  
        Iframe iframe =(Iframe)this.getFellow("rpt");
        File f = new File(reportDest);
        byte[] buffer = new byte[(int) f.length()];
        FileInputStream fs = new FileInputStream(f);
        fs.read(buffer);  
        fs.close();
        ByteArrayInputStream is = new ByteArrayInputStream(buffer);
        AMedia amedia = new AMedia(namafile, "pdf", "application/pdf", is);
             
        iframe.setContent(amedia);
    }
  
     
    
    /*EDIT FORM CODE*/
    public void EditView(String cidcust)throws Exception {
        Textbox tidcust=(Textbox)this.getFellow("idcust");
        Textbox tnamecust=(Textbox)this.getFellow("namecust");
        Textbox taddress=(Textbox)this.getFellow("address");
  
        Connection Conn = new DBSQLConnection().openConnection();
        Statement st = Conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM CUSTOMER WHERE IDCUST='"+cidcust+"'");
			while (rs.next()){
                tidcust.setValue(rs.getString("idcust"));
                tnamecust.setValue(rs.getString("namecust"));
                taddress.setValue(rs.getString("address"));
			}
         actionType="Edit";
    }
    
  
    /*DELETE RECORD FORM CODE*/
    public void DeleteView(String cidcust)throws Exception {
        SQL="DELETE FROM CUSTOMER WHERE IDCUST=?";
  
        Connection Conn = new DBSQLConnection().openConnection();
        PreparedStatement prep = Conn.prepareStatement(SQL);
        prep.setString(1, cidcust);
        prep.executeUpdate();
        Conn.close();
         
        Messagebox.show("Data has been Delete successfully..","Data Delete",Messagebox.OK,Messagebox.INFORMATION);   
               
        viewlist();        
  
    }
    
    /*CLEAR TEXT To ENTRY*/
    public void cleartext()throws Exception {
        Textbox tidcust=(Textbox)this.getFellow("idcust");
        Textbox tnamecust=(Textbox)this.getFellow("namecust");
        Textbox taddress=(Textbox)this.getFellow("address");
        tidcust.setValue("");
        tnamecust.setValue("");
        taddress.setValue("");
        tidcust.setFocus(true);
        actionType="Entry";
     }
}
  



C. Tutorial Youtube 





D. Note 

 

 

 

 

 

Free Templates Source Code Simple Project Java ZK Framework

  Free Templates Source Code Simple Project Java ZK Framework   ZK Framework aims to combine the simplicity and security from its server-cen...