【发布时间】:2011-06-10 19:21:00
【问题描述】:
我将 JSF2.0 与 Spring Webflow 2.3 一起使用。
我一直在尝试获取有关在我的页面中点击了哪些链接以及点击了多少次的信息。现在,当我留在流程中并转到另一个流程时它可以工作,但是当我重定向然后返回时,它只会重置我的 bean。我觉得我错过了一些东西,但我不知道是什么。
我已经尝试了我的小脑袋能想到的所有事情,我也尝试过研究,但我的猜测是我的搜索参数不正确,因为我找到的所有内容都无济于事。
这是我的支持 bean:
@SessionScoped
public class CountBean implements Serializable{
private static final long serialVersionUID = 7498596369206276696L;
private static Log logger = LogFactory.getLog(CountBean.class);
private String link;
private Map<String,Integer> counter;
public CountBean(){
if(counter == null || counter.isEmpty()){
counter = new LinkedHashMap<String,Integer>();
}
link = null;
}
public void countTheCount(){
if(link != null){
int value;
if(counter.containsKey(link)){
value = counter.get(link);
value++;
counter.put(link, value);
} else {
value = 1;
counter.put(link, value);
}
logger.debug("Click: "+link+" , times: "+value);
}
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
}
这是我的流程:
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="testBean" class="be.admb.myadmbresearch.beans.TestBean" />
<var name="countBean" class="be.admb.myadmbresearch.beans.CountBean" />
<view-state id="test-view" model="testBean">
<transition on="logTest">
<evaluate expression="testBean.testWarning()" />
<evaluate expression="countBean.countTheCount()" />
</transition>
<transition on="gotoxy" to="sample-view">
<evaluate expression="countBean.countTheCount()" />
</transition>
<transition on="gotoab" to="sample-redirect-view">
<evaluate expression="countBean.countTheCount()" />
</transition>
<transition on="gotogoogle" to="gotoGoogle-view">
<evaluate expression="countBean.countTheCount()" />
</transition>
</view-state>
<view-state id="sample-redirect-view" view="externalRedirect:contextRelative:sample.html" />
<view-state id="gotoGoogle-view" view="externalRedirect:http://www.google.be" />
<view-state id="sample-view">
<transition on="keerdekewere" to="test-view">
<evaluate expression="countBean.countTheCount()"/>
</transition>
</view-state>
编辑:忘记添加重定向的样本流:
<var name="countBean" class="be.admb.myadmbresearch.beans.CountBean" />
<view-state id="sample-view" >
<transition on="keerdekewere" to="test-view">
<evaluate expression="countBean.countTheCount()"/>
</transition>
</view-state>
<view-state id="test-view" view="externalRedirect:contextRelative:test.html" />
如果有人可以帮助我,甚至想到任何事情,我将非常感激。
提前致谢。
拉斐尔
【问题讨论】:
标签: jsf-2 spring-webflow