Thursday, November 11, 2010

Setting up quick log4j for testing

Just put the following code on top of your code:


BasicConfigurator.configure();
log.setLevel(Level.DEBUG);

Wednesday, November 10, 2010

log.debug not working in grails unit test

Use the following method call to enable debug level messages to be printed.

mockLogging(grails_artifact_class, true)

where, grails_artifact_class is domain/controller/service class.

Friday, November 5, 2010

Exception while starting grails from STS

Problem: Getting java.lang.ClassNotFoundException: sun.tools.native2ascii.Main while starting grails application from STS.

Solution: Go to build path. Change your default system JRE to JDK. You are good!

Friday, October 29, 2010

Specifying JVM in STS

Although STS is build on top of elcipse it uses STS.ini instead of eclipse.ini for inititializing startup parameter. You need to specify JVM in this file as follows:

-vm
C:/Program Files/Java/jdk1.6.0_22/bin/javaw.exe

Make sure:
  1. -vm and the path are in two seperate line.
  2. This option is set before -vmargs.

Tuesday, November 10, 2009

Test your webpages in multiple version of IE browser using IETester

It has been always a problem to install multiple version of IE on same computer and testing our web pages in different version of IE. IETester eliminates this problem. It can simulate multiple version of Internet Explorer.

Download IETester here.

Sunday, October 18, 2009

jQuery - How To ...

How to get selected option value?
var optionValue = $("#DropdownId option:selected").val();


How to check existance of an HTML element?
$("#elementId").size()>0
or
$("#elementId").length>0

If you know any cool jQuery expression please post it here...

Inter Portlet Communication between Pageflows in Weblogic Portal

Well, Weblogic documentaions are too good, but I had to put considerable effort to make it work. To explain the inter portlet communication between two pageflow let's take this use case.

1. Pageflow PublisherController will publish a custom event.
2. Published custom event will carry a payload.
3. This custom event will be consumed by ConsumerController pageflow.
4. It will extract the payload from the event.

Publisher pageflow

@Jpf.Controller
public class PublisherController extends PageFlowController {
@Jpf.Action(forwards = { @Jpf.Forward(name = "success", path = "index.jsp") })
public Forward publish() {
PortletBackingContext ctx = PortletBackingContext.getPortletBackingContext(getRequest());
ctx.fireCustomEvent("myCustomEvent", "I am from Publisher pageflow.");
return new Forward("success");
}
}


Backing file

public class EventBacking extends AbstractJspBacking {
public void captureEvent(HttpServletRequest request, HttpServletResponse response, Event event) {
CustomEvent custEvent = (CustomEvent)event;
Serializable payload = (Serializable)custEvent.getPayload();
PortletBackingContext ctx = PortletBackingContext.getPortletBackingContext(request));
String ipcPayloadAttrName = ctx.getInstanceId() + "_ipcPayload";
HttpSession session = request.getSession();
session.setAttribute(ipcPayloadAttrName, payload);
}
}


Consumer pageflow

@Jpf.Controller()
public class ConsumerController extends PageFlowController {
@Jpf.Action(forwards = { @Jpf.Forward(name = "default", path = "index.jsp") })
public Forward consume() {
PortletBackingContext ctx = PortletBackingContext.getPortletBackingContext(getRequest());
String message = (String)getSession().getAttribute(ctx.getInstanceId() + "_ipcPayload");
getSession().removeAttribute(ctx.getInstanceId() + "_ipcPayload");
return new Forward("default");
}
}

To be contd...