Showing posts with label JSF. Show all posts
Showing posts with label JSF. Show all posts

Monday, May 11, 2015

Cool tools for UML diagrams drawing for java, cpp and others.

Hi,
Recently I have come across the following tools for drawing different UML diagrams. If you are using OOP like Java , CPP and others then these free tools are suitable for you.
  1. VISUAL PARADIAGM
  2. MODELIO
  3.  ???
This list is not exhaustive please I have USED any such tool please share your experience with us.

Friday, March 28, 2014

hide a component in jsf

Sometimes it happens that you want to hide some of your components so that they become invisible to users.
And you may suddenly wonder how to achieve that or which option to use. Fine, JSF makes it pretty easy for you to do that by using the rendered  option which is a boolean with either true or false.
e.g:

this component will become invisible. 

Tuesday, February 25, 2014

Production tips#5 : Glassfish Master Password

What is the master master password often referred to in Glassfish ? In this post I sharing with you some of the basic points regard the master password that can help you to administer your server confidently.

The master password is a password that is used to encrypt the DAS or Domain Administration Server and the instances keystores (IKS). The DAS and IKS used it to open instances at startup.
Another point worth mentioning is that the master password is not transmitted over the network nor is it used for authentication.
It is saved for the DAS and all the  instances in the domain. Contrary to what you may have in mind, the default master password is 'changeit' and not 'adminadmin'
For each domain like domain1 is it located inside  C:\glassfishv3\glassfish\domains\domain1
cmd: asadmin> create-domain  --savemasterpassword domain1

Start a domain:
asadmin> start-domain domain1

stop a domain:
asadmin> stop-domain domain1

You will have noticed that you are not prompted to enter the master password when it is starting the DAS just because it has been saved.

Change master password for a domain:
asadmin> change-master-password --savemasterpassword domain1

Delete a domain:
asadmin> delete-domain domain1


Monday, February 24, 2014

Production tips#4 : Create a secured domain in Glassfish console and assign it to the GUI in netbeans

What is really the issue here ?
Suppose you want to have your Netbeans IDE and an embedded Glassfish server GF attached to it. By default the web administration console page is not password protected. If you go directely to the web admin console page and change the admin password and hope it to work chances are that you will disappoint yourself. 
If that is the case then what to do ?
1. Go to the command prompt and navigate into the C:\glassfishv3\glassfish\bin.
   Clik on asadmin.bak
    or cd C:\glassfishv3\glassfish\bin
C:\glassfishv3\glassfish\bin> asadmin [ENTER]
asadmin > create-domain --adminport 5555--savemasterpassword domain3
 Follow the shell instruction it is interactive but enter your admin username, admin password and master password (at least 6 characters )
2. Assign the domain we just created to GUI so that we don't need to use the command line or asadmin shell  every time for the server administration.
 Go to Netbeans --> Services -->Servers :
        Right click Servers and Add a Glassfish server
 
Click Next  -->Next  and you are here
 Specify the same domain name you created previously : domain3
 
Finish and Restart you IDE, you can now visit the admin web console page by just right clicking the server name and click View Domain Admin Console  like here below
 Congratulation you just did it, feel to comment ...

Friday, January 10, 2014

Getting a org.springframework.beans.factory.BeanCreationException with my first Maven, Spring Project

If you are getting this error message, you maybe missing a crucial jar file in your project. Just download the spring- jar include it to your project, build it and move forward.

Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

Facing this problem can be very painful, I have been and lost a couple of my precious hours trying to dig it out. I won't talk much because it is not my field of predilection. I am pragmatic and let us go straight to the point.
Solution:
You have download two jars and include in your project.
  1. commons-javaflow
  2. spring- jar
Hopefully you have include them, build your project and regain your smiling face. Happy coding day though  !!!

Friday, January 3, 2014

Disable autocomplete in JSF

Are you fed up with autocomplete in JSF and want to disable it at all costs ?
<h:inputText value="#{myBean.name}" autocomplete="off"/>
Just refresh your page and move on.

Tuesday, December 31, 2013

No library found for this namespace error in PrimeFaces

This silly error message usually occurs if you are using a PrimeFaces 3.0 version onward. With older version of PrimeFaces (less than 3.0) we used to make the following declaration:
xmlns:p="http://primefaces.prime.com.tr/ui"
However from 3.0 the following declaration need to be used instead:
xmlns:p="http://primefaces.org/ui"
So far so good, hopeful the road block is lifted .
Enjoy it.

Tuesday, December 3, 2013

What is JSF ?

JSF stands for Java Server Faces and blah blah blaah. Among these multiple definitions of JSF I come to keep one that says almost everything in few words and leave the task to anyone to dilute. JSF is a component oriented and event driven web framework to build up web applications. JSF after all is a standard and has many implementations Oracle ADF, Apache MyFaces, IBM and last the one so dear to me is the Sun reference implementation.
 As an event driven and component oriented framework, jsf nice integrate all the members of the MVC:
  •  Model: managed beans
  • View: components
  • Controller: faces servlet
So this is in short how you may look at JSF...

Sunday, November 24, 2013

Glassfish or Tomcat for your Production Project ?

This post is dedicated to those new in J2EE especially in JSF who are certainly wondering what will their choice of web application to deploy maybe their first ever enterprise web application on production. From my experience to make your life easier, Glassfish is the way to go, and I may mention that I have nothing against Uncle Tommy. Glassfish offers everything from development to the administration out of the box and free to you to smoothly deploy your application.
Such as :
  •  Command line utilities
  • Easy to use administration GUI
  • Multiple security features
  • Clustering features
  • Very good documentation
  • Stability
 For more details information feels free to google Glassfish Vs Tomcat to hear what other folks out there are gossiping about.
The following paragraph is taken from Chapter  3 of the Book entitled: " Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications" by Mick Knutson.

   GlassFish is a complete Java EE application server, in contrast to a Servlet container that would provide the Java EE web profile capabilities. GlassFish has an open source and supported version, and is described by the java.net project as:
   An open source, production-ready, Java EE-compatible application server. GlassFish version 3 provides a small footprint, fully-featured implementation of Java EE 6.
The Java EE 6 platform significantly improves developer productivity, introduces the lightweight Web Profile for Web-centric applications, and includes the latest versions of technologies such as JAX-RS 1.1, JavaServer Faces (JSF) 2.0, Enterprise JavaBeans (EJB) 3.1, Java Persistence (JPA) 2.0, Context and Dependency Injection (CDI) 1.0, and more. GlassFish is a Java EE open source application server.
    Apache Tomcat is maintained by the Apache foundation and described as:
Apache Tomcat is an open source software implementation of the Java Servlet
and JavaServer Pages technologies. The Java Servlet and JavaServer Pages
specifications are developed under the Java Community Process.
Tomcat is an excellent choice for projects that do not require enterprise services from Java EE.



Monday, November 11, 2013

getting day, month and year form java.util.Date

You may be trying to get for example the day, month and year from the java.util.Date directly such as:
Date date;
          int day =  date.getDay();
          int month = date.getMonth();
          int year = date.getYear();

         Just know that this previous way of getting them (d,m,y) is deprecated and only lead you to mess. However you should rather use the Calendar to get what you want from the date object, and here is how:

 Date date;
 Calendar calendar = Calendar.getInstance();
 calendar.setTime(date);
 int day = calendar.get(Calendar.DAY_OF_MONTH);
 int month= calendar.get(Calendar.MONTH);
 int year= calendar.get(Calendar.YEAR);

Hope you feel released...

Note: Of course importing from java.util.*;

Tuesday, October 1, 2013

Thousands or comma separator in JSF

Are you working with a financial application and now thinking about formatting your result with thousand separator ? Then don't worry. Don't even think about using javascript or whatever folks out there. In fact the converter offered by jsf make it easy to the job and even more given the list of other attributes available.

Suppose your total is declared as follows:

BigDecimal annualBugdet;

your setter and getter may also be defined :

public void setAnnualBugdet( BigDecimal annualBugdet) {

 this.annualBugdet = annualBugdet.setScale(2,RoundingMode.HALF_EVEN);
}


public BigDecimal  getAnnualBugdet( BigDecimal annualBugdet) {


 return annualBugdet;
}


your bean is then called from the view as :

<h:outputText value="#{yourBean.annualBugdet}" > <f:convertNumber groupingUsed="true" maxFractionDigits="2" currencySymbol="$" > </h:outputText>

Thursday, August 29, 2013

Checking characters in textfield in jsf with ajax

One of the cool features of JSF is its easier and simpler handling of Ajax. Oh yes have a look.
Suppose I want to check the length of the characters entered in the textfield live using jsf.


Using the following codes:

Finally we have
As an image is worth thousands words. No more comments.
Just rock !!!

Wednesday, January 30, 2013

IP restriction with jsf and glassfish

After completing one of my j2ee application I needed to secure it but how ?
The first idea that came into my mind was to develop my own custom security module. What I did but somewhere along the lines I change my mind for a built-in REALM.

Implementing the built-in security that come with glassfish is straight forward
as you can see from these blogs
  1. http://blog.eisele.net/2011/01/jdbc-security-realm-and-form-based.html
  2. http://jugojava.blogspot.com/2011/02/jdbc-security-realm-with-glassfish-and.html
  3. http://www.greenkode.com/2011/09/user-authentication-and-authorization-using-jaas-and-servlet-3-0-login/ 
Everything  went smoothly I realize there was no simple option in glassfish that could allow me to prevent some ip address  from accessing my application. Even thought we can use virtual server  and certificates to do the job, I found them advanced and difficult .

An easier way to do this will just be to use the following

HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); 
String ip = httpServletRequest.getRemoteAddr();
To get the incoming ip and .... rocks!!

I will be back on this topics soon