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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:42:47+00:00 2026-05-25T21:42:47+00:00

I am trying to debug an issue with the following code: <h:panelGroup id=items> <ui:repeat

  • 0

I am trying to debug an issue with the following code:

<h:panelGroup id="items">
<ui:repeat value="#{itemController.items}" var="item">
    <h:form>
        <h:inputText id="title" value="#{item.fields['Title']}"/>
        <a4j:commandButton action="#{dao.storeItem(item)}" value="Save" render="@form"/>
    </h:form>
</ui:repeat>
</h:panelGroup>

The above works if a collection is displayed in the view directly. However, if the ui:repeat starts empty, and items are added through an AJAX request, and the ui:repeat rerendered, the forms break. Specifically the model is not updated, nor actions triggered. I want to understand why.

Right now my guess is that if the ui:repeat starts empty, the form component is not created at all. Can anyone verify this, or provide the correct explanation?

ADDITIONAL INFO

Here are relevant parts of the controller, I have also tried ViewScoped, and long-running conversations:

@Named
@ConversationScoped
public class ItemController implements Serializable
{   
    private static final long serialVersionUID = 1L;

    @Inject
    private HibernateDAO dao;    

    public List<Item> getItems()
    {
        return dao.getItems();
    }

    public void uploadListener(final FileUploadEvent event)
    {
        final UploadedFile item = event.getUploadedFile();

        final FacesContext context = FacesContext.getCurrentInstance();
        final Application application = context.getApplication();
        final String messageBundleName = application.getMessageBundle();
        final Locale locale = context.getViewRoot().getLocale();
        final ResourceBundle resourceBundle = ResourceBundle.getBundle(messageBundleName, locale);

        final String msg = resourceBundle.getString("upload.failed");
        final String detailMsgPattern = resourceBundle.getString("upload.failed_detail");

        try
        {
            CSVImporter.doImport(item.getInputStream(), dao, item.getName());
        }
        catch (ParseException e)
        {
            final Object[] params = {item.getName(), e.getMessage()};
            final String detailMsg = MessageFormat.format(detailMsgPattern, params);
            final FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, detailMsg);

            context.addMessage("uploadForm:uploader", facesMsg);
        }
        catch (TokenMgrError e)
        {
            final Object[] params = {item.getName(), e.getMessage()};
            final String detailMsg = MessageFormat.format(detailMsgPattern, params);
            final FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, detailMsg);

            context.addMessage("uploadForm:uploader", facesMsg);
        }
    }
}

The dao simple fetches the items from a database. Here is the relevant fileupload code:

<h:form id="uploadForm" enctype="multipart/form-data">          
    <h:message id="message" showDetail="true" for="uploader" errorClass="error" warnClass="warning" infoClass="info" fatalClass="fatal"/>
    <rich:fileUpload id="uploader"
        fileUploadListener="#{itemController.uploadListener}"
        maxFilesQuantity="1"
        acceptedTypes="csv"
        render="items message" />            
</h:form>
  • 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-25T21:42:47+00:00Added an answer on May 25, 2026 at 9:42 pm

    Okay posting it here because it will be longer than comments .

    It works for me which is probably not what you wanted to hear 🙁 but I had to teak few minor things . Firstly in controller add

    public void storeItems(Item item)
    {
      dao.storeItems();
    }
    

    then change this

     <a4j:commandButton action="#{dao.storeItem(item)}" value="Save" render="@form"/>
    

    to

    <a4j:commandButton action="#{itemController.storeItem(item)}" value="Save" render="@form"/>
    

    That however is probably not the real issue and I think that is around here

    CSVImporter.doImport(item.getInputStream(), dao, item.getName());
    

    basically I am expecting that the method above would have uploaded data from where dao.getItems(); can fetch it. So put a breakpoint at public List<Item> getItems() and once file has been upload and render="items message" renders the items panel group again it should will hit this method and at that time see if dao.storeItems() is bringing any data back which it should. Reply back then and we will take it from there.


    Update below to avoid running dao fetch twice.

    You can not avoid two calls to your get thats part of JSF lifeCycle and is normal.
    How ever you can avoid hitting the database twice as you should too but refactoring your code along the lines of

     private List<Item> items;
    
        public List<Item> getItems()
        {
            return items;
        }
    
        @PostConstruct
        public void init()
        {
            this.items = dao.getItems();
        }
    
    
        public void uploadListener(FileUploadEvent  event) throws Exception{
            ......
            CSVImporter.doImport(item.getInputStream(), dao, item.getName());
            this.items = dao.getItems();
    
            .....
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to debug an issue with a server and my only log file is
I am trying to debug an issue involving a ClassCastException in Java. In the
I'm trying to debug an issue that only occurs when my iPhone app receives
I am trying to debug a strange issue with users that have LogMeIn installed.
I'm currently trying to debug a customer's issue with an FTP upload feature in
I'm trying to debug an application (under PostgreSQL) and came across the following error:
I'm trying to debug an issue myself. May post it later if I fail
I'm trying to debug an issue that is really stumping me. Basically, I have
I am trying to debug an issue that happens on our testing server. So
I am trying to connect to twitter via TwitterVB and the following code does

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.