Tuesday, June 8, 2010

Which is the controller class for JSF? FacesServlet

Important servlet classes for JSF framework which is very similar to struts framework are
org.apache.myfaces.webapp.StartupServletContextListener
and javax.faces.webapp.FacesServlet - All the requests map to this servlet
These 2 servlets are defined in the web.xml situated in WEB-INF directory.

Faces Servlet
javax.faces.webapp.FacesServlet
1



Faces Servlet
/faces

So all the request must start with /faces to match the url pattern. Now this FacesServlet object creates an object called FacesContext which in turn contains 3 objects i.e ServletContext, ServletRequest and ServletResponse objects which are passed to the service method of the FacesServlet. Next is the processing. The processor is an object called Lifecycle. The FacesServlet servlet hands over control to the Lifecycle object. The Lifecycle object processes the FacesContext object in six phases.

Java POS Printer - Retail

Recently I was working on Java Pos Printers also called thermal printers used in stores to print receipt, or in cinema halls to give you tickets.Yes that small machine which prints your bills and tickets . I have been working on printing a receipt in that using JPOS APIs. So for people who reach this site searching for stuff related to that I will try my best to transfer all my knowledge I could get regarding this.

First of all what we need is a thermal printer, its drivers (search for Java drivers of that particular printer). Once you get the Java drivers, which will be in zip file, unzip and read any ReadMe.txt file provided.Put all the jar files in class path and all the dlls in the path.

After this go to javapos.com website and from there download a sample posiflex example and try to run the demo file. Set all of its jars also in class path before running. If all goes well you should be able to test your printer on firing a print command.