• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Marcos APS
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic