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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:32:34+00:00 2026-06-14T12:32:34+00:00

I am writing a composite component that is intended to wrap an input element,

  • 0

I am writing a composite component that is intended to wrap an input element, and augment it with an ‘optional field’ designation and h:message element below it.
Here is the component (in input.xhtml file):

<composite:interface/>
<composite:implementation>
  <div>
  #{component.children[1].setStyleClass(component.children[1].valid ? '' : 'inputError')}
    <composite:insertChildren/>
  </div>
  <h:panelGroup styleClass="optional" 
      rendered="#{!component.parent.children[1].required}" 
      layout="block" >
    #{msgs['common.optional.field']}
  </h:panelGroup>
  <h:message id="msgId" 
       for="#{component.parent.children[1].id}" errorClass="error"/>
</composite:implementation>

Again, the intended usage of the component is to wrap an h:input* element which is expected to be the first and immediate child of it in a using page.

In a using page I would then write:

    <h:form id="f1">
    <h:panelGrid border="0" columns="2" style="width: 80%">
        <f:facet name="header">
            <col width="40%" />
            <col width="60%" />
        </f:facet>
        <h:outputLabel styleClass="sectionBody" for="i1"
            value="Input 1"></h:outputLabel>
            <my:input id="ii1">
            <h:inputText id="i1" size="20" maxlength="20" tabindex="0"
            required="true" label="Input 1">
            </h:inputText>
            </my:input>
        <h:outputLabel styleClass="sectionBody" for="i2"
            value="Input 2"></h:outputLabel>
            <my:input id="ii2">
            <h:inputText id="i2" size="20" maxlength="20" tabindex="0"
                label="Input 2">
            </h:inputText>
            </my:input>
    </h:panelGrid>
    <br />
    <h:commandButton value="Submit" tabindex="1">
        <f:ajax listener="#{terminalImportBean.addTerminal}" 
          execute="@form" render="@form"/>
    </h:commandButton>
</h:form>

This would work just fine using normal posts.
However if I add add f:ajax validation for “Input 1″ (id=”i1”) and try to re-render the composite (ii1) using the following:

...   
         <h:outputLabel styleClass="sectionBody" for="i1"
            value="Input 1"></h:outputLabel>
         <my:input id="ii1">
            <h:inputText id="i1" size="20" maxlength="20" tabindex="0"
            required="true" label="Input 1">
               <f:ajax listener="#{myBean.checkInput1}" 
                  event="blur" 
                  render="ii1"/>
            </h:inputText>
         </my:input>
...

I gen an error in the browser during ajax response processing:

malformedXML: During update: f1:ii1 not found

I tried using f1:ii1, :f1:ii1, but to no avail. When I use msgId or :f1:ii1:msgId it works. Does anybody know why?

I am using Mojarra 2.1.3

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-06-14T12:32:36+00:00Added an answer on June 14, 2026 at 12:32 pm

    That’s because the composite component does by itself not render anything to the HTML. Only its children are been rendered to HTML. There does not exist any HTML element with ID f1:i11 in the generated HTML output. Open the page in browser, rightclick and View Source. Look in there yourself. There’s no such element with that ID. JavaScript/Ajax is encountering exactly the same problem. It can’t find the element in order to update it.

    To solve this, you’d need to wrap the entire composite body in a HTML <div> or <span> and assign it an ID of #{cc.clientId} which basically prints UIComponent#getClientId().

    <cc:implementation>
        <div id="#{cc.clientId}">
            ...
        </div>
    </cc:implementation>
    

    Then you can reference it as below:

    <my:input id="foo" />
    ...
    <f:ajax ... render="foo" />
    

    You can even reference a specific composite component child.

    <f:ajax ... render="foo:inputId" />
    

    See also:

    • Is it possible to update non-JSF components (plain HTML) with JSF ajax?
    • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Facelets composite component that switches between using inputText and inputSecret based
A pretty normal case: We have a 'portlet' composite component that has two states:
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing documentation in html requires some code examples. What to do with characters that
Writing a client application that sends images to a server via a webservice. As
I'm writing a set of C# composite web server controls for displaying dialog boxes.
I've read some articles about writing composite components in JSF 2 and even about
I'm writing some extension modules for a WPF Composite application supplied by another vendor.
I'm writing an ASP.NET custom composite control (Inherits System.Web.UI.WebControls.CompositeControl). By default my control mark
I am writing .NET3.5, WPF application using Composite Application Library. Application is divided into

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.