문제

<h:form>
<h:commandButton value="Buy" styleClass="button-buy" actionListener="#{basketCount.incrementBasketCount}" immediate="true">
</h:commandButton>
</h:form>

jsf2 part:

 <li class="basket">    
  #{basketCount.basketCount}
 </li>

faces-config:

 <managed-bean>
  <managed-bean-name>basketCount</managed-bean-name>
  <managed-bean-class>main.BasketCount</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>

simple bean for action listening:

package main;

import java.io.Serializable;

    public class BasketCount implements Serializable {

     private static final long serialVersionUID = -4576074045587545642L;

     int inBasketCount = 0;

     public void incrementBasketCount(javax.faces.event.ActionEvent event) {
      inBasketCount++;
     }

     public int getBasketCount() {
      return inBasketCount;
     }

    }

use case:
1. click on "Buy" button
2. content of basket is incremented
3. click Shift-Ctrl-Del (clean cookie and cache) in FF and Refresh
4. counter of basket remained same

As I understand, session scope specifies,that this counter (step 2) will be incremented in session scope only, and after cookies,cache clean up should be resetted?

The problem,that it does not.

도움이 되었습니까?

해결책

Resolved by providing persistent cookies

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top