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

  • Home
  • SEARCH
  • 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 880799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:09:27+00:00 2026-05-15T12:09:27+00:00

My previous for the same problem , Now, I am in a same situation

  • 0

My previous for the same problem , Now, I am in a same situation and looking for some solutions / suggestions.

My Restrictions are

  1. My Bean has to be request scoped
  2. I cannot use tomahawk – we use a customized app server built on tomcat + SOA – blah , blah so we cannot use.

I have a collection of search results which is different for each search criteria (and thats why the bean is request scoped – because the user would want to use diff tabs in the same browser to compare results or do whatsoever he wants ). I like to show the search results in pages like prev + next.

like this :

<tr>
    <td colspan="14" class="WhiteRowSmallText">
        <div align="right">
            <h:commandLink rendered="#{adminBean.showPrev}" action="#{adminBean.goPrev}">
                <h:outputText> &lt; Prev  &#160;|&#160;</h:outputText>
            </h:commandLink>
            <h:outputText> &#160;|&#160; </h:outputText>
            <h:commandLink rendered="#{adminBean.showNext}" action="#{adminBean.goNext}">
                <h:outputText> Next &gt;</h:outputText>
            </h:commandLink> &#160;
        </div>
    </td>
</tr>

Instead of hitting Database for every ‘Next’ click, I wanted to store them in session, like

public static Object getSessionMapValue(String key) {
    Log.debug(CLASS_NAME + "getSessionMapValue: key=" +key );
    return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key);
}

public static void setSessionMapValue(String key, Object value) {
    Log.debug(CLASS_NAME + "setSessionMapValue: key=" +key );
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key, value);
}

My Questions are :

If I use this approach to store a huge number of search results , will it still be available if the user opens up another tab ? I think so – is not it ?

When the results were more, i tried ‘Next’ , it did not even call its action method because a new Bean was created (!) and made that showNext as ‘false’ – What are my options to allow the user to browse thru pages considering my restrictions above ?

Is it okay to use a hidden Bean variable and make it ‘true’ through javascript when the link was clicked and in the CustomPhaseListener – and in the RESTORE VIEW PHASE – make the showNext as ‘true’ based on this hidden value? is that a worth approach?

All scoldings and suggestions are welcome.

If you use inputHidden,you may get ClassCast Exception , I am trying like this,not sure yet, if this works

public Boolean getShowNextValue() { if(showNext != null && showNext.getValue()!= null) { log.debug("showNext.getValue() ]" +showNext.getValue()); if(((String)showNext.getValue().toString()).equals("false")) { return false; }else{ return true; } }else{ return false; } }
  • 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-15T12:09:27+00:00Added an answer on May 15, 2026 at 12:09 pm

    If I use this approach to store a huge number of search results , will it still be available if the user opens up another tab ? I think so – is not it ?

    I’d just make the bean session scoped. Alternatively, you can also split all “to-be-session-scoped” properties out of the request scoped bean and create a new session scoped bean with those properties. You can then make use of the JSF managed-property facility to inject the session scoped one (for data) in the request scoped one (for actions) whenever needed. Also see this example.

    You however need to keep in mind that this might eat more memory when the webapp is more busy and concurrently visited.

    When the results were more, i tried ‘Next’ , it did not even call its action method because a new Bean was created (!) and made that showNext as ‘false’ – What are my options to allow the user to browse thru pages considering my restrictions above ?

    That’s because the bean is request scoped and the properties responsible for the condition of the rendered attribtue did not have the same outcome during apply request values phase of the subsequent request as it was during the render response phase of the initial request. Solutions to that are answered in your previous question (as you linked yourself).

    Is it okay to use a hidden Bean variable and make it ‘true’ through javascript when the link was clicked and in the CustomPhaseListener – and in the RESTORE VIEW PHASE – make the showNext as ‘true’ based on this hidden value? is that a worth approach?

    If Tomahawk is really not an option, I’d go for a <h:inputHidden> with binding.

    E.g.

    <h:inputHidden binding="#{adminBean.showPrev}" />
    <h:commandLink rendered="#{adminBean.showPrevValue}">
        ...
    

    with

    private HtmlInputHidden showPrev = new HtmlInputHidden(); // +getter +setter.
    

    and

    public void setShowPrevValue(Boolean showPrev) {
        showPrev.setValue(showPrev);
    }
    
    public Boolean getShowPrevValue() {
        return (Boolean) showPrev.getValue();
    }
    

    Use the last getter/setter instead when you want to get/set the “real” boolean value in your bean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Explicit is better than implicit but if you really don't… May 15, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer Here is an algorithm that shows you how to do… May 15, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer You can't change the order for different nodes. You can… May 15, 2026 at 1:24 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.