开发者

How to change ContentURI in Weblogic Portlet?

I am developing an application which uses Weblogic portlets and Struts. All I need to do is to load different jsp's in the same portlet based on the web browser that client is using.

For eg: If I have a portlet called home.portlet. If the user is using IE it should display IE.jsp in the home.portlet, if he is using firefox I should display firefox.jsp in home.portlet.

This is what I have in home.portlet:

<netuix:content>
        <netuix:jspContent contentUri="IE.jsp"/>
    </netuix:content>


 //in struts config file
 <forward name="firefox" path="/firefox.jsp>

This is what I did to ac开发者_如何学Gohieve it- In homeAction.java:

if(firefox)
return mapping.findForward("firefox");

So even if the user is using firefox it is displaying IE.jsp. How can we change the jsp content in the portlet from the Struts Action Class so that I can check the kind of the browser the user is using and display the page accordingly??

All help and suggestions appreciated.

Thanks,

-Sai


You will have to check for browser in your homeAction.java and do the forward based on that.

Try this to check browser version in your action.

public void checkBrowserType (HttpServletRequest req)
{
   String s = req.getHeader("user-agent");
   if (s == null)
      return;
   if (s.indexOf("MSIE") > -1)
      System.out.println("using Internet Explorer");
   else if (s.indexOf("Netscape") > -1)
      System.out.println("using Netscape");
   // etc ...   
}


My portlets wern't configured for struts. I changed that now, and its working fine.

EG:

<netuix:strutsContent action="getStudentList" module = "people/students"
  refreshAction = "getStudentList" reqestAttrpersistence="none"/>

And then in the action class I am checking for the browser and displaying the appropriate jsp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜