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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:44:26+00:00 2026-05-24T19:44:26+00:00

What is the proper way to pass a model object used in Spring Web

  • 0

What is the proper way to pass a model object used in Spring Web Flow to a Controller?

My use case is as follows:

I have a flow and the end state displays a model object that contains some calculated results. That works good. I also have a link on the page to generate a pdf to display the results. That too works fine if I manually set the model object.

So how do I get the model object used in the flow to the controller? Or is there a cleaner way to view pdfs using webflow?

Thanks

  • 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-24T19:44:26+00:00Added an answer on May 24, 2026 at 7:44 pm

    @John V. thank you your post did help me in the right direction. This is what I have working now:

    in my flow.xml

    <view-state id="summary" view="summary.jsp">
        <on-entry>
            <set name="result" value="conversationScope.result" />
            <evaluate expression="printPDF" />
        </on-entry>
        <transition on="startOver" to="startOver" />
    </view-state>
    

    in my webflowContext.xml file

    <bean id="printPDF" class="com.example.actions.PrintPDF"/>
    

    PrintPDF.class

    public class PrintPDF extends AbstractAction {
    
        @Override
        public Event doExecute(RequestContext context) {
    
            Result obj = (Result)context.getFlowExecutionContext().getConversationScope().get("result");
            HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getNativeRequest();
            req.getSession().setAttribute("result", obj);
            return success();
        }
    
    }
    

    in my controller

    @RequestMapping(method=RequestMethod.GET, value="/pdf")
    public ModelAndView showPDF(ModelMap model, HttpServletRequest request) {
        Result result = (Result)request.getSession().getAttribute("result");
        model.addAttribute("result", result);
        return new ModelAndView("PDF", model);
    }
    

    PDF is defined as a bean in my spring-pdf-views.xml file

    <bean id="PDF" class="com.example.view.PDF">
        <property name="url" value="/pdf/example.pdf" />
    </bean>
    

    That class contains the following:

    public class PDF extends AbstractPdfStamperView {
    
        @Override
        protected void mergePdfDocument(Map<String, Object> model, PdfStamper stamper, 
                HttpServletRequest request, HttpServletResponse response) throws Exception {
    
            Result result = (Result)model.get("result");
    
            AcroFields form = stamper.getAcroFields();
    //map form fields
    

    and finally the jsp has a link like

    <a href="/pdf.html">
    

    I hope that can help someone else. I am not sure if that is the most efficient way of doing it but I am open to any suggestions.

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

Sidebar

Related Questions

What's the proper way to create a hyperlink in Spring+JSP? There must be a
I've been trying to find a proper way to pass some information, such as
What's the proper way to pass an array of strings from managed C++ to
I have two activities in which I need to pass an object array between
What is the proper way to pass an answer (a collection) back to Silverlight?
I have string query in and pass @Date object to string. It is giving
I have a meta class for the Django User model that I use to
What is the most proper way to sending email of minimal 1000 or more
What's the proper way to convert from a scientific notation string such as 1.234567E-06
What is the proper way to minimize a WinForms app to the system tray?

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.