Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:16:41+00:00 2026-05-23T01:16:41+00:00

I’m using JSF2.0 with Spring Webflow 2.3 . I’ve been trying to get information

  • 0

I’m using JSF2.0 with Spring Webflow 2.3 .

I’ve been trying to get information on what link has been clicked in my page and how many times it has been clicked. Now it works when I stay in the flow and just go to another flow but when I redirect and then return it just resets my bean. I feel like i am missing something but i don’t know what.

I’ve tried about everything my little head can think off and i’ve tried researching but my guess is my search parameters aren’t correct cause all I find doesn’t help.

This is my backing 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;
}


}

And this is my flow:

<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>

Edit: Forgot to add the redirected sample-flow:

<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" />

If anyone could help me or even think of anything i would be very gratefull.

Thanks in advanced.

Rafael

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:16:42+00:00Added an answer on May 23, 2026 at 1:16 am

    I’ve fixed it by using a HttpSession directly setting the counter eachtime i run countTheCount(), now this seems to work but i don’t know if it is the right solution, some feedback would be nice.

    This is what i got:

    public CountBean(){
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        if(session != null){
            counter = (Map<String, Integer>) session.getAttribute("counter");
        if(counter == null || counter.isEmpty()){
            counter = new LinkedHashMap<String,Integer>();
            session.setAttribute("counter", counter);
        }
        }
        link = null;
    }
    
    public void countTheCount(){
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        if(link != null){
        int value;
        if(counter.containsKey(link)){
            value = counter.get(link);
            value++;
            counter.put(link, value);
            session.setAttribute("counter", counter);
        } else {
            value = 1;
            counter.put(link, value);
            session.setAttribute("counter", counter);
        }
        logger.debug("Click: "+link+" , times: "+value);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.