Sunday, October 30, 2016

Ajax have been very popular among developers. Almost all websites using ajax as part of the application is built, because it is dynamic and certainly more lightly.

This time, let's make a simple example application web application. we create a form submit that send data to a database with the help of jQuery without refreshing the page.


Friday, August 26, 2016

Getter and Setter in Java

When we create a Java class, familiarize attributnya set with an access level other than the public, such as private or protected for security reasons. Okay, we use private or protected access levels for attributes. to access these attributes need to be made getters and setters method. Setter method used to set the value of the attribute while Getter method used to retrieve attribute values. Both of these methods (Getter and Setter) set the level of public acces. If later we learn JavaServer Faces (JSF) or hibernate and Java Persistence API (JPA), we will often use this method getters and setters. In JSF getters and setters is imperative to access the class attribute on the backing bean. Similarly, in hibernate / JPA, entity classes using this method getters and setters. Therefore getters and setters mastered this method, because this is important. ContohKelasPakaiGetterSetter class example:
public class ContohKelasPakaiGetterSetter {private String nim; private String name; protected String address; protected String department;
public String getNim () {return nim; } Public void setNim (String nim) {this.nim = nim; } Public String getNama () {return name; } Public void setNama (String name) {this.nama = name; } Public String getAlamat () {return address; } Public void setAlamat (String address) {this.alamat = address; } Public String getJurusan () {return directions; } Public void setJurusan (String subject) {this.jurusan = majors; }}
Then we make the caller grade class ContohKelasPakaiGetterSetter
public class KelasPemanggilGetterSetter {public static void main (String [] vera) {// Set the attribute value objects class instance // ContohKelasPakaiGetterSetter ContohKelasPakaiGetterSetter ContohKelasPakaiGetterSetter objekKelas_1 = new (); objekKelas_1.setNim ( "AAA111"); objekKelas_1.setNama ( "PAK Beye"); objekKelas_1.setAlamat ( "Cigondewah"); objekKelas_1.setJurusan ( "Science Palak");
ContohKelasPakaiGetterSetter ContohKelasPakaiGetterSetter objekKelas_2 = new (); objekKelas_2.setNim ( "BBB222"); objekKelas_2.setNama ( "ANI YUDO"); objekKelas_2.setAlamat ( "Cikawao"); objekKelas_2.setJurusan ( "Agricultural Sciences"); // Retrieves the value of the attribute objects // ContohKelasPakaiGetterSetter String class instanc nim_1 = objekKelas_1.getNim (); String nama_1 = objekKelas_1.getNama (); String alamat_1 = objekKelas_1.getAlamat (); String jurusan_1 = objekKelas_1.getJurusan (); String nim_2 = objekKelas_2.getNim (); String nama_2 = objekKelas_2.getNama (); String alamat_2 = objekKelas_2.getAlamat (); String jurusan_2 = objekKelas_2.getJurusan (); // Show the output value of the attributes of each object System.out.println ( "NIM" + nim_1 + "\ tNAMA:" + nama_1 + "\ tALAMAT:" + alamat_1 + "\ tJURUSAN:" + jurusan_1); System.out.println ( "NIM" + nim_2 + "\ tNAMA:" + nama_2 + "\ tALAMAT:" + alamat_2 + "\ tJURUSAN:" + jurusan_2); }}
when class KelasPemanggilGetterSetter in execution results:
NIM: AAA111 NAME: PAK Beye ADDRESS: DEPARTMENT Cigondewah: Palak Science NIM: BBB222 NAME: ANI YUDO ADDRESS: DEPARTMENT Cikawao: Agricultural Sciences
in the example above, there are four classes of attributes,
nim -> Access level private name -> Access level private address -> access level protected majors -> access level protected
then there is a method getters and setters for each attribute of the class,
public String getNim () public void setNim (String nim) public String getNama () public void setNama (String name) public String getAlamat () public void setAlamat (String address) public String getJurusan () public void setJurusan (String subject)
to re-set the value we use the setter method: objekKelas_1.setNim ( "AAA111"); objekKelas_1.setNama ( "PAK Beye"); objekKelas_1.setAlamat ( "Cigondewah"); objekKelas_1.setJurusan ( "Science Palak"); To retrieve the attribute values ​​used getter method: String nim_1 = objekKelas_1.getNim (); String nama_1 = objekKelas_1.getNama (); String alamat_1 = objekKelas_1.getAlamat (); String jurusan_1 = objekKelas_1.getJurusan (); setter method serves to provide value, while separately taking our value funakan getter method.