XHTML 1.0 Validation Error for JSF ViewState

| Posted by watashii | Filed under Java, Programming, Web

When the <h:form> tag is used in JSF, the ViewState hidden input tag is generated in the XHTML page.  However this generates an autocomplete attribute which is an invalid XHTML 1.0 (Strict/Transitional) markup.

Read the rest of this entry »

Tags: , , ,

Getting the HttpServletRequest from PortletRequest Object

| Posted by watashii | Filed under Java, Programming, Web

In my JSF / icefaces based portlet running on Weblogic Portal, I got the following error:
com.icesoft.faces.webapp.http.portlet.PortletExternalContext cannot be cast to javax.servlet.http.HttpServletRequest

It turned out I cannot simply obtain the HTTPServletRequest object like this:

FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest portletRequest = (HttpServletRequest) ctx.getCurrentInstance().getExternalContext().getRequest();

In a portlet environment, to get the request/response objects, we must obtain the javax.portlet.PortletRequest/PortletResponse objects instead (which inherits methods from java.servlet.HTTPServletRequest/HTTPServletResponse):

FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();

However sometimes we may require the HttpServletRequest / HttpServletResponse object.  To obtain this, we must extract an attribute from the PortletRequest / PortletResponse object:

FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();
HttpServletRequest httpServletReq = (HttpServletRequest) portletReq.getAttribute("javax.servlet.request");

Tags: , , , , , ,

Using JSF 1.2 on Oracle Workshop for Weblogic (Portal 10.3)

| Posted by watashii | Filed under Java, Programming, Web

When choosing facets during the creation of a new portal web project, the built-in Sun RI JSF 1.2 (together with JSTL 1.2)  facets cannot be selected.  Here are the recommended (by Oracle) steps to get around this problem.  Note that this is because Apache Beehive Page Flow has a dependecy with  JSF 1.2, therefore only follow this if not using the page flow integration components provided by Beehive.

Read the rest of this entry »

Tags: , , , ,