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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:05:46+00:00 2026-06-08T18:05:46+00:00

This questions seems to be so simple, yet I didn’t find the mistake. Ok,

  • 0

This questions seems to be so simple, yet I didn’t find the mistake.

Ok, here we go: I have a form with a List of IPs (whatever),
IP n: [INPUT-FIELD] [Button “Add”]
IP n+1: [INPUT-FIELD] [Button “Add”]
These IPs exist right from the start.
They are initialized in the Constructor of the Managed Bean.

When I click on the “Add” Button, the current IP is validated. After that
I add another entry to my java.util.List and another line in the
JSF form appears:

IP n+2: [INPUT-Field] [Button “Add”]

and so on.

Adding a line (with a new IP) and validating the current IP
work perfect for the existing values IP n and IP n+1,
but validating and adding does NOT work with the dynamically
added IP n+2. Neither validating the dynamically generated input field
works nor adding another line with the newly created “Add”-Button.

What am I doing wrong?

<h:form id="frmSpecial" prependId="false">
    <h:panelGroup id="tblDestFw">
        <c:forEach items="#{bean.fwdest}" var="fwdest">
            IP: <h:inputText value="#{fwdest.ip}" validator="#{bean.validateIP}"/>
            <h:commandButton action="#{bean.addFwDest()}" 
                             value="&gt;&gt;" title="Add another line">
                <f:ajax execute="@this" render="tblDestFw"/>
            </h:commandButton>
            <br/>
        </c:forEach>
    </h:panelGroup>
</h:form>

@ManagedBean(name = "bean")
@ViewScoped
public class EnterNewSystemFW implements Serializable {
     List<FirewallDest> fwdest;
     public EnterNewSystemFW() {
         fwdest.add(new FirewallDest("N"));
         fwdest.add(new FirewallDest("N+1"));
     }

     public void addFwDest() {
         fwdest.add(new FirewallDest());
     }
}

Thanks.

Bernd

  • 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-06-08T18:05:47+00:00Added an answer on June 8, 2026 at 6:05 pm

    As to adding the new line, your <c:forEach> references a view scoped bean property. Due to JSF issue 1492, this bean is reconstructed on every request.

    Replace it by a normal JSF component like <ui:repeat> or <h:dataTable> and it’ll work as expected.

    <ui:repeat value="#{bean.fwdest}" var="fwdest">
        ...
    </ui:repeat>
    

    As to performing validation, your <f:ajax execute="@this"> processes only the current component (the command button), not the inputs. Use <f:ajax execute="@form"> instead to process the entire form.

    See also:

    • JSTL in JSF2 Facelets… makes sense?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a pretty simple question, but I have not managed to find
I read few questions here on SO about this topic which seems yet confusing
This seems like a simple question, but has proven to be difficult to find
this seems like a simple enough question but I can't seem to find a
This seems like such a simple question. I have several Edit boxes on my
Yet another Scrabble project question... This is a simple one. It seems I am
This question seems mind-boggling simple, yet I can't figure it out. I know you
I have a rather interesting question that seems simple to answer, yet I have
This seems like a simple question, but it is difficult to search for. I
This seems to be an embarrassingly simple question, but, after a day of reading

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.