iceface 2.0:如何在冰封中保留价值?

时间:2010-12-03 03:44:12

标签: jsf jsf-2 icefaces

我想将冰推整合到我的网络应用程序中。

我有一个页面(placeinfo.jsf)显示一个地方的信息和ui:include weather.jsf,用于该地方的天气信息。

用户可以访问http://xxx.com/xxx/placeinfo.jsf?place=california页面。

简单的代码示例,
placeinfo.jsf
1)ice:输出值=“placeInfoBean.population”
2)ice:输出值=“placeInfoBean.language”
3)ui:include src =“./ weather.xhtml”

weather.jsf
1)ice:输出值=“weatherBean.humidity”
2)ice:输出值=“weatherBean.visibility”

PlaceInfoBean.java

@ManagedBean(name="placeInfoBean")
@RequestScoped
public class PlaceInfoBean
{
    String population;
    String language;

    @PostConstruct
    public void init()
    {
       HttpServletRequest request= (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
       String place = request.getParameter("place");
       setPopulation(PlaceInfoDao.getPopulation(place));
       setLanguage(PlaceInfoDao.getlanguage(place));
    }
}

WeatherBean.java

@ManagedBean(name="weatherBean")
@RequestScoped
public class WeatherBean
{
    String humidity;
    String visibility;

    @PostConstruct
    public void init()
    {
       HttpServletRequest request= (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
       String place = request.getParameter("place");
       setHumidity(WeatherDao.getHumidity(place));
       setVisibility(WeatherDao.getVisibility(place));
    }

    public WeatherBean()
    {
        PushRenderer.addCurrentSession("weather");
    }
}

我有另一页更新天气,方法调用
   的 PushRenderer.render( “天气”);
   WeatherBean实际上做了刷新,postconstrust方法再次运行,但发现没有请求“地方”的参数,假设是“加利福尼亚”,然后页面无法正常工作。

问题:
1)我可以知道除了会话之外,在PushRenderer做某事之前页面如何记住该值?
2)获取WeatherBean的请求参数是否正确?    或请求param应该由placeInfo.jsf的ui:param传递?
   如何在WeatherBean中获取ui:param的值?

谢谢!

1 个答案:

答案 0 :(得分:0)

您是否尝试将托管bean设置为@SessionScoped?还是@ApplicationScoped?它有效吗?