因为这里例子涉及到三个应用,分别部署在三个Server上,这三个应用的开发人员可能不同,这正是开发Portal应用的魅力:用标准的方式集成大家开发的应用。
这里我们假设用户已经开发好了一个天气预报的Web应用。开发工具:JDeveloper 11.1.1.5.0。
该应用非常简单,只有一个普通的jsp页面:weather.jsp,不过大家可以把它想象成一个复杂的应用,比如从后台访问数据库获取数据,然后再展示到前台。
weather.jsp内容如下:根据zipcode参数值,返回该地区的天气状况,是以逗号间隔的CSV格式。
之所以用这种格式,是为了展示ADF URL Service Data Control功能,在下一篇文章将会介绍。
<% if (request.getParameter("zipcode") == null || request.getParameter("zipcode").equals("")) { out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,55,Rainy.gif,45,0,Rainy,94065 Tuesday,85,Sunny.gif,80,0,Sunny,94065"); out.println("Wednesday,61,PartlyCloudy.gif,50,0,Partly Cloudy,94065"); out.println("Thursday,80,PartlyCloudy.gif,70,0,Cloudy,94065"); out.println("Friday,63,Rainy.gif,50,0,Rainy,94065 Saturday,70,Rainy.gif,55,0,Rainy,94065"); out.println("Sunday,68,PartlySunny.gif,50,0,Partly Sunny,94065"); } else if (request.getParameter("zipcode").equals("94065")){ out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,55,Rainy.gif,45,0,Rainy,94065 Tuesday,85,Sunny.gif,80,0,Sunny,94065"); out.println("Wednesday,61,PartlyCloudy.gif,50,0,Partly Cloudy,94065"); out.println("Thursday,80,PartlyCloudy.gif,70,0,Cloudy,94065"); out.println("Friday,63,Rainy.gif,50,0,Rainy,94065 Saturday,70,Rainy.gif,55,0,Rainy,94065"); out.println("Sunday,68,PartlySunny.gif,50,0,Partly Sunny,94065"); } else if (request.getParameter("zipcode").equals("60001")) { out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,55,Rainy.gif,45,0,Rainy,60001"); out.println("Tuesday,85,Rainy.gif,80,0,Rainy,60001"); out.println("Wednesday,61,PartlyCloudy.gif,50,0,Partly Cloudy,60001"); out.println("Thursday,80,PartlyCloudy.gif,70,0,Cloudy,60001"); out.println("Friday,63,Rainy.gif,50,0,Rainy,60001"); out.println("Saturday,70,Rainy.gif,55,0,Rainy,60001"); out.println("Sunday,68,PartlyCloudy.gif,50,0,Partly Sunny,60001"); } else if (request.getParameter("zipcode").equals("90001")) { out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,70,PartlyCloudy.gif,55,0,Partly Cloudy,90001"); out.println("Tuesday,80,PartlyCloudy.gif,70,0,Cloudy,90001"); out.println("Wednesday,85,PartlyCloudy.gif,80,0,Sunny,90001"); out.println("Thursday,68,PartlySunny.gif,50,0,Partly Sunny,90001"); out.println("Friday,63,PartlySunny.gif,50,0,Partly Sunny,90001"); out.println("Saturday,61,PartlyCloudy.gif,50,0,Partly Cloudy,90001"); out.println("Sunday,55,Rainy.gif,45,0,Rainy,90001"); } else if (request.getParameter("zipcode").equals("94401")) { out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,55,Sunny.gif,45,0,Sunny,94401"); out.println("Tuesday,85,Sunny.gif,80,0,Sunny,94401"); out.println("Wednesday,61,Sunny.gif,50,0,Sunny,94401"); out.println("Thursday,80,Sunny.gif,70,0,Cloudy,94401"); out.println("Friday,63,PartlyRainy.gif,50,0,Partly Sunny,94401"); out.println("Saturday,70,PartlySunny.gif,55,0,Partly Sunny,94401"); out.println("Sunday,68,PartlySunny.gif,50,0,Partly Sunny,94401"); } else if (request.getParameter("zipcode").equals("94402")) { out.println("dayOfWeek,hiTemp,img,lowTemp,precip,sky,zipCode"); out.println("Monday,55,Rainy.gif,45,0,Rainy,94402"); out.println("Tuesday,85,Rainy.gif,80,0,Rainy,94402"); out.println("Wednesday,61,PartlyCloudy.gif,50,0,Partly Cloudy,94402"); out.println("Thursday,80,PartlyCloudy.gif,70,0,Cloudy,94402"); out.println("Friday,63,Sunny.gif,50,0,Sunny,94402"); out.println("Saturday,70,Sunny.gif,55,0,Sunny,94402"); out.println("Sunday,68,PartlySunny.gif,50,0,Partly Sunny,94402"); } %>
应用重要开发步骤如下:
(1)
(2)
(3)
(4)创建Web WAR Deployment Profile的最简单的方法是:右键web.xml。
(5)
(6)发布到Admin Server上,这里我们假定Admin Server是部署传统Java EE应用(JSP、Servlet、EJB)的地方。
(7)访问http://pmma-cn:7001/WeatherJSPApp/weather.jsp。
应该能够返回一个CSV格式的数据,看起来有些“丑陋”,是不是?
查看页面源码,你会发现这是一个CSV格式的数据,该数据将作为我们的数据源,后面主要工作就是怎样把这个CSV数据,以表格的形式呈现在Portal应用中。
Project下载:WeatherJSPApp.7z 。
(未完待续)
没有评论:
发表评论