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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:52:21+00:00 2026-05-13T00:52:21+00:00

I am creating a JSF application. I have some items (e.g. products) from database

  • 0

I am creating a JSF application. I have some items (e.g. products) from database and I want to create a JSF page for editing particular items, that is:

  • it should display selected item properties and enable user to edit them,
  • I want to be able to view this item with some link,
  • I want JSF to somehow remember that I’m editing particular item (e.g. after editing its data it should display this item page)

I have a problem with storing/passing id of item being edited. I saw that in sample JSF CarDemo application they store item (car) being viewed in session. I don’t want to do this because I want user to be able to edit different elements in separate browser tabs.

I tried several approaches:

  • using some (e.g. itemId) GET parameter in URL, but it makes it difficult to go back to item page after editing data (to-view-id field in faces-config.xml can only contain constants),
  • using some backing bean managed-property and passing its value in each hyperlink and in forms (by adding hidden field)

The problem I still can’t eliminate is that if after editing some item properties I try to save them and validation (e.g. f:validateLength) fails the page is reloaded but id of item being edited is lost. I think it is quite standard task when creating web applications (e.g. user edition, store products edition) so there certainly should be some solution.

Thanks in advance.

  • 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-13T00:52:21+00:00Added an answer on May 13, 2026 at 12:52 am

    Tomahawk‘s t:saveState does exactly what you want. Just have something like in your page:

    <t:saveState value="#{bean.item.id}" />
    

    or if you want to cover all “uncovered” item values:

    <t:saveState value="#{bean.item}" />
    

    If you don’t want to add another component library for some unknown reasons (I do recommend Tomahawk though, it adds more flexible components on top of standard JSF implementation, e.g. t:dataList, t:dataTable preserveDataModel="true", t:selectOneRadio layout="spread", t:inputFileUpload, etcetera), then you could also use the standard <h:inputHidden> component to pass hidden parameters from request to request (it renders an <input type="hidden">). One caveat is that you will still lost the values when the validation phase fails. But this can be workarounded by using the component binding instead of the value.

    private HtmlInputHidden itemId = new HtmlInputHidden();
    private Item item = new Item();
    
    public void editItem() { // Action method when selecting an item for edit.        
        itemId.setValue(item.getId());
    }
    
    public void saveItem() { // Action method when saving edited item.
        item.setId((Integer) itemId.getValue());
    }
    

    and in the JSF page have the following in the same form:

    <h:inputHidden binding="#{bean.itemId}" />
    

    Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 230k
  • Answers 230k
  • 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 The following links might help: VM means Virtual Machine. See… May 13, 2026 at 1:58 am
  • Editorial Team
    Editorial Team added an answer You need to call the DWM API functions, which are… May 13, 2026 at 1:58 am
  • Editorial Team
    Editorial Team added an answer Use the -Xmx JVM option to increase the Java maximum… May 13, 2026 at 1:58 am

Related Questions

I am creating a small modal form that is used in Winforms application. It
I am creating a program that will be installed using the .net installer project.
I am creating a GUI for a machine that runs remote (WinXP) or on
I am creating a Windows Service in C# that processes messages from a queue.
I am creating a windows service and want to know best practices for this.

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.