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 3607612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:23:51+00:00 2026-05-18T21:23:51+00:00

Im using JSF time ago, and i see that the concept of MODEL is

  • 0

Im using JSF time ago, and i see that the concept of MODEL is really important there. Here, on struts2, i see that this concept is a bit obsolete. For example, seems that is impossible to set a Bean session scoped; instead i need to put the whole Bean (object) into the session (manually).

So, in some methods, this is not nice.
For example, for the page-switch, i have implemented (on JSP page) this :

<s:div cssClass="content" id="content">
<%
    String pageValue=request.getParameter("page");
    if((pageValue!=null) && (pageValue.compareTo("articles")==0)) {
        %>
            <s:include value="articles/articles.jsp"></s:include>
        <%
    } else {
        %>
            <s:include value="homepage/homepage.jsp"></s:include>
        <%
    }
%>
</s:div> 

is this the right way to work with Struts2? Or is better put some values into Beans and generate the page accordings to the Beans values? (Model concept, but REALLY i don’t know hot to set the Bean scope, and i wont put them on session. Else is like do procedual coding, and i can use PHP to do this :)).

I Don’t know how to do it otherwise 🙂

Cheers

  • 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-18T21:23:52+00:00Added an answer on May 18, 2026 at 9:23 pm

    There are several ways…

    1) Struts uses spring for DI, you too can use spring for this purpose look into the struts2-spring-plugin

    2) You can use SessionAware as I mentioned in a previous question. However I did mention that interceptors work in conjunction because session scoped objects are cross cutting concerns by their very nature. Without the interceptors a solution will be forced to exist in your actions or worse the view layer… repeated over and over… which as you put it “is not nice”.

    3) If you are strongly MVC oriented look into modelDriven and scopedModelDriven. The later will set a model for your action which can be in the session scope (other scopes are possible) if the model does not exist then it will be instantiated for you… This is good for multi page forms, the successful completion of the form can then remove this object. I don’t really like modelDriven it can complicate access to the Action.

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

Sidebar

Related Questions

I have a JSF page (using MyFaces 2.0) that does a bit of data
This is the first time I am using prime 3.3.1 with JSF 2.1. I
Here's my scenario: I'm using JSF. I have a page that refreshes every 5
I am using JSF 2.0 Mojarra. I need to create a Managed Bean that
I am using JSF validation to simply check that the length of a field
How can i read UI Components(text box,label,buttons etc.,) and positions in Panel Using JSF?.This
I am using this code in JSF.: <c:if test=#{sV.done.booleanValue()}> <option value=#{sV.id} selected=selected>#{sV.text}</option> </c:if> <c:if
I am using iText+flying saucer for the first time with xhtml pages using JSF
I m creating an app using JSF. The problem I have is that every
Its been quite some time since i have started developing web pages using JSF

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.