• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Script is not rendered after postback in a composite component added programmatically

Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this composite component:


In my last question:


I was getting this error:

when trying to add the above composite component programmatically with this code:

but I managed to solve this problem this way:

The implementation of the method Components#includeCompositeComponent from OmniFaces 2.4 (the version I was using) is this:

So I decided to give a try to the code from an earlier version of OmniFaces (with some change adding the attributes parameter from me) of this method:

And finally the error was gone. The composite component was dynamically added to the page.

But another problem appeared.

The action in a button to add the component is more or less like this:

As you can see, the composite component is only added once.

When the component is first added, the script code that is in the component:

is added to the page. I can see it when I visualize the html source code in the browser. But on postbacks, this script code is not rendered anymore. It's not in the genereted html page. The <h:outputScript> with target="head" is rendered everytime, as expected, but not this one.

From my point of view, maybe there's still someting missing in the assembling of the composite component code in the method above to fix the script code even on postbacks on the page. I really don't know. It's just a guess.

Do you know what's going on or what's missing?

P.S.: Cross-posted: http://stackoverflow.com/questions/39606719/script-is-not-rendered-after-postback-in-a-composite-component-added-programmati
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic