0

How to convert String date into Date obj

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

try
{
Date today = df.parse("10/12/2009"); //converts String object into Date Object
System.out.println("Today = " + df.format(today)); //formats the Date object accourding to the format mentioned above
} catch (ParseException e)
{
e.printStackTrace();
}

|
0

Javascript confirm in aj4:commandLink in JSF

in ,

<a4j:commandLink onclick="if (! window.confirm('Are you sure?') ) {return false}" immediate = "true" >

don't forget to add immediate = 'true';



|
0

Setting Java Managed Bean into Session

FacesContext.getCurrentInstance().getExternalContext()
               .getSessionMap().put( "testBean",
                     testBean );

TestBean testBean = (TestBean)FacesContext.getCurrentInstance().getExternalContext()
               .getSessionMap().get( "testBean")

|
1

How-to get or remove a jsf backing bean from session?

To reset session bean

FacesContext
.getCurrentInstance()
.getApplication()
.createValueBinding( "#{yourBeanName}").setValue(FacesContext.getCurrentInstance(), null );



To get session bean reference

Object obj = FacesContext
.getCurrentInstance()
.getApplication()
.createValueBinding("#{yourBeanName}")
.getValue(FacesContext.getCurrentInstance());
 
YourSessionBean bean = (YourSessionBean)obj;

|
0

Prepended L in Exception

Have you ever saw an exception with L padded before a exception???


like .executeQuery(Ljava/lang/String;)Ljava/sql/ResultSet  while running an application in your application server ?
It means that this method cannot be found on server.

The solution is to restart the server...



|
2

ISO 8583 Encoder / Decoder

This page might help you if you want to encode and decode a test message


|
0

Getting HTTP Session in JSF


Here is a way to get HttpSession...

import javax.faces.context.FacesContext;
// …..
public void addInSession() {
MySession mySession = new MySession();
mySession.setName(getMsg());
/* .getSession(bool), true if we want to create new session, if want to
use old
session then false
*/
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
session.setAttribute(”sessionObj”, mySession);
if (session.getAttribute(”sessionObj”) != null) {
MySession mySavedSession = (MySession) session.getAttribute(”sessionObj”);
System.out.println(”HTTP Session: ” + mySavedSession.getName());
} else {
// do something
}
}

|

Copyright © 2009 So That I Can Remember All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.