indiWiz.com

Subhash's Tech Log

Archive for the ‘javaee’ tag

JBoss Application Server 5.0.0 GA Released

without comments

Download it from here: http://www.jboss.org/jbossas/downloads/. If I remember correctly, the first beta was released more than two years back.

Written by Subhash Chandran

December 9th, 2008 at 5:30 am

Posted in Java,news

Tagged with , ,

DI Example Using Spring

without comments

Based on a brief tutorial by a colleague of mine (Selvaraj S), I developed a small “Hello World” kind of example for Spring 2.5. The example is in Maven format, and can be downloaded from here.

Written by Subhash Chandran

December 5th, 2008 at 9:02 am

Posted in Java

Tagged with , ,

JSR-286: Adding Header Elements

without comments

Some HTML elements like <link>, <script> may need to be placed in the HTML’s <head> section. For such needs, JSR-286 defines a standard way:

import javax.portlet.GenericPortlet;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.MimeResponse;
import org.w3c.dom.Element;

...

public class MyPortlet extends GenericPortlet {
  @Override
  protected void doHeaders(RenderRequest request, RenderResponse response){
    Element e = response.createElement("link");
    e.setAttribute("rel", "stylesheet");
    e.setAttribute("type", "text/css");
    e.setAttribute("href", "abc.css");
    response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, e);
  }
}

response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, ...) might be called for adding any number of headers.

We also have to add this in the portlet.xml (either in portlet scope or application scope):

<container­-runtime­-option>
  <name>javax.portlet.renderHeaders</name>
  <value>true</value>
</container­-runtime­-option>

This is because javax.portlet.renderHeaders is set to false by default.

Written by Subhash Chandran

November 19th, 2008 at 3:23 pm

Posted in Java

Tagged with , ,