Forum Stats

  • 3,874,204 Users
  • 2,266,682 Discussions
  • 7,911,768 Comments

Discussions

Including a page fragment that has a clientListener

jflack
jflack Member Posts: 1,524 Bronze Trophy
edited Apr 16, 2013 10:26AM in JDeveloper and ADF
I'm using JDeveloper 11.1.2.3. I have a page fragment (.jsff) that was originally written to be used in a bounded task flow added to pages in an af:region. It was working fine. But now, I need to call a JavaScript function to update an inputText when a commandButton is pressed. I know how to do this, but have never done it in a fragment.

The question is that I need to make sure that the Javascript function is present on any page that uses the fragment. This is done with an af:resource component, but since af:resource is a child of af:document, and af:document is not used in a fragment, I can't put the af:resource in the fragment. As far as I can see, my options are:
<ul>
<li>Put the af:resource on every page that uses the task flow containing the fragment (the fragment and a parent-action are the only things in the task flow). If I do this, can the clientListener in the fragment see the Javascript function on the calling page?</li>
<li>This doesn't NEED to be a task flow. Maybe I should reference the fragment with ui:include instead of af:region. If I do this, I THINK I can use af:resource in the fragment. But I also need to get the fragment's pageDef into the calling page's pageDef - can I use the &lt;page&gt; element in the calling page's pageDef to include it? Or do I need to merge the two pageDefs?</li>
</ul>
Tagged:

Best Answer

Answers

  • Sudipto Desmukh
    Sudipto Desmukh Member Posts: 2,287
    The question is that I need to make sure that the Javascript function is present on any page that uses the fragment.
    This is done with an af:resource component, but since af:resource is a child of af:document, and af:document is not used in a fragment, I can't put the af:resource in the fragment
    This is not true , you can put af:resource tags in jsff as well. Works perfectly fine.
    Ref : https://blogs.oracle.com/jdevotnharvest/entry/using_afresource_tag_in_page_fragments
  • jflack
    jflack Member Posts: 1,524 Bronze Trophy
    edited Apr 13, 2013 2:02PM
    I tried it before writing the question. With the af:resource tag in the fragment, the page doesn't run. Without it, it does. Weirdly - with the tag, it just hangs, no error, just never shows.

    What I've done so far is option 2 - used ui:include to put the fragment on the page. A &lt;page&gt; element in the calling page's pageDef doesn't seem to work to include the fragment's pageDef (unless I set the "path" attribute wrong). That confirms what I've read on this forum - consensus is that there is no way to reference one pageDef from another one. Too bad - that would be a nice enhancement, ADF developers. So I merged the fragment's pageDef into the parent's pageDef, which works fine.

    I should call this answered because option 2 works, but it will be a pain to do it on every page that includes the fragment - kind of negates the benefit of using fragments. I'm going to have to try option 1. Any comments on option 1, folks?
  • Sudipto Desmukh
    Sudipto Desmukh Member Posts: 2,287
    af:resource tag in jsff's works fine for me. Can you please paste your source code ?
  • jflack
    jflack Member Posts: 1,524 Bronze Trophy
    edited Apr 16, 2013 10:26AM
    Okay, I'm officially nuts. I tried it again in an af:region, with the af:resource in the fragment, and it worked fine. You are correct, af:resource is OK in a fragment, even when the fragment is added via a bounded task flow.

    I still have a problem - but that will be a new question.

    Edited by: jflack on Apr 16, 2013 10:22 AM
This discussion has been closed.