Requirement Constraints

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 22 September 2010

My Quick Reference

Posted on 01:02 by Unknown
Class with Static data which Returns as List

package demo.combobox.simple_combobox;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ShirtData {

private static List<String> colors = new ArrayList<String>();
private static List<String> sizes = new ArrayList<String>();

static{
colors.add("blue");
colors.add("black");
colors.add("white");

sizes.add("small");
sizes.add("medium");
sizes.add("large");
}

public static final List<String> getColors() {
return new ArrayList<String>(colors);
}

public static final List<String> getSizes() {
return new ArrayList<String>(sizes);
}
}





How to cast an Object to an int in java?

http://stackoverflow.com/questions/3661413/how-to-cast-an-object-to-an-int-in-java


If you're sure that this object is an Integer :

int i = (Integer) object;

Or, starting from Java 7, you can equivalently write:

int i = (int) object;

Beware, it can throw a ClassCastException if your object isn't an Integer and aNullPointerException if your object is null.

This way you assume that your Object is an Integer (the wrapped int) and you unbox it into an int.

int is a primitive so it can't be stored as an Object, the only way is to have an intconsidered/boxed as an Integer then stored as an Object.




If your object is a String, then you can use the Integer.valueOf() method to convert it into a simple int :

int i = Integer.valueOf((String) object);

It can throw a NumberFormatException if your object isn't really a String with an integer as content.








Java Inner class example




import java.util.*;

public class SampleVM {

private List<MyData> names = new ArrayList<MyData>();

public SampleVM() {
names.add(new MyData("name 1",true));
names.add(new MyData("name 2",false));
names.add(new MyData("name 3",false));
names.add(new MyData("name 4",false));
names.add(new MyData("name 5",false));


}


public List<MyData> getNames() {
return names;
}
public class MyData{
String name;
boolean open;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
public MyData(String name, boolean open) {
super();
this.name = name;
this.open = open;
}
}
}


 


Hibernate Where in clause to Delete multiple items

	@Override
public void deletePracticeAppMenu(List<Long> prAppMenuIDs, Long practiceID) {
String query = "delete from PracticeAppMenu where PrAppMenuID in (:appMenuIDs) and practiceID = :pracid ";
Query q = getCurrentSession().createQuery(query);
q.setParameterList("appMenuIDs", prAppMenuIDs);
q.setParameter("pracid", practiceID);
q.executeUpdate();
}

Read More
Posted in Today Tech Stuff | No comments
Newer Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • ZK Example for inline Editing with Add New and Delete
    I am quite impressed on this demo from ZK . But adding new record and delete existing record is missing as part of typical CRUD. So i thoug...
  • Hibernate Validator Example 2
    In this example, we will see some more validation constraints such as @email, @past, @length, etc. And also we will also define custom error...
  • ZK Passing Parameter between two files using MVVM–Part 1
    Overview This is the first series of articles about Passing parameter between two zul files using MVVM Design pattern .This article will fo...
  • ZK Border Layout–Another example
    This examples show how you can use ZK Border Layout to show the product information on clicking image. ZK Version 6 Project Name : BorderL...
  • EDI 270–5010 Documentation - ISA – Interchange Control Header
    ISA – Interchange Control Header ISA – Interchange Control Header   The ISA is a fixed record length segment and all positions within ea...
  • ZK MVVM Form Binding CRUD with Spring and Hibernate - Part 11
    Storing Image in the Database          My Sincere thanks to Joshi who helped me in this article In the last article , we have successfu...
  • ViewModel Class Java Annotation @Init, @NotifyChange, @Command
    In following sections we'll list all syntaxes that can be used in implementing a ViewModel and applying ZK bind annotation. The ZK binde...
  • Load Tab box Content on Demand Using MVVM
    ZK Version : 6.5.0 CE In this post, let us see how we can load individual ZUL File on each tab box content Step : 1 First let us create indi...
  • ZK MVVM Form Binding CRUD with Spring and Hibernate - Part 4
    Presentation Layer using ZK Framework          In part 3 , We have completed Spring integration with hibernate. In this post, we will des...
  • ZK composite component Example
    Thanks to benbai for helping me in the ZK Forum to complete this example. This example shows how to create our own component using ZK C...

Categories

  • Billing Process
  • C Workbook
  • C++ Workbook
  • Eclipse Tips
  • EDI 5010
  • EMR Appointment Features
  • EMR Labs Stuff
  • EMR PMS Links
  • EMR Use cases
  • EMR Vital Sign
  • Good Website Design
  • Hibernate Criteria Queries
  • Hibernate Introduction
  • Hibernate Introduction Setup
  • Hibernate Mapping
  • Hibernate POC
  • Hibernate Validator
  • Hibernate–Java Environment setup
  • HPI
  • Java
  • Maven
  • MU Certification
  • NPI
  • PQRS
  • Practice Management System
  • Spring Security
  • Tech Links
  • Today Tech Stuff
  • zk
  • ZK Hibernate
  • ZK 5 Databinding
  • ZK Application
  • ZK Calling Another ZUL
  • ZK CheckBox
  • ZK CreateComponents
  • ZK CSS
  • ZK extended Components
  • ZK Foreach
  • ZK Forum Posts
  • ZK Framework
  • ZK Hibernate Setup
  • ZK ID Space
  • ZK Include
  • ZK Installation
  • ZK iReport
  • ZK Layout
  • ZK Listitem Pagination
  • ZK Message Box
  • ZK MVC
  • ZK MVC Combox Box
  • ZK MVC CRUD Examples
  • ZK MVC Listbox
  • ZK MVVM
  • ZK MVVM Combo
  • ZK MVVM CRUD
  • ZK MVVM ListBox
  • ZK Spring
  • ZK TextBox

Blog Archive

  • ►  2013 (105)
    • ►  December (3)
    • ►  September (7)
    • ►  August (13)
    • ►  July (1)
    • ►  June (11)
    • ►  May (3)
    • ►  April (14)
    • ►  March (19)
    • ►  February (21)
    • ►  January (13)
  • ►  2012 (177)
    • ►  December (1)
    • ►  November (13)
    • ►  October (19)
    • ►  September (24)
    • ►  August (26)
    • ►  July (6)
    • ►  June (37)
    • ►  May (30)
    • ►  April (16)
    • ►  March (1)
    • ►  January (4)
  • ►  2011 (5)
    • ►  December (1)
    • ►  November (1)
    • ►  July (1)
    • ►  June (1)
    • ►  April (1)
  • ▼  2010 (1)
    • ▼  September (1)
      • My Quick Reference
Powered by Blogger.

About Me

Unknown
View my complete profile