Forum Stats

  • 3,871,977 Users
  • 2,266,360 Discussions
  • 7,911,017 Comments

Discussions

How to render any APEX Component's HTML

Vincent Morneau
Vincent Morneau Member Posts: 11
edited Feb 14, 2014 12:50PM in APEX Discussions

Hi,

I am looking to get the actual HTML that some APEX views are generating at runtime.

Let's take APEX_APPLICATION_PAGE_ITEMS for example. I've got item P1_INPUT from application_id 150.

I am looking for an API that would return something like this :

get_item_html(application_id => 150, item_name => 'P1_INPUT') which would return something like

<input type="text" id="P1_INPUT" name="p_t04" class="text_field" value="" size="30" maxlength="4000">

Is this possible?

Thanks.

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,427 Red Diamond
    vincent.morneau wrote:
    
    I am looking to get the actual HTML that some APEX views are generating at runtime.
    
    Let's take APEX_APPLICATION_PAGE_ITEMS for example. I've got item P1_INPUT from application_id 150.
    
    I am looking for an API that would return something like this :
    
    get_item_html(application_id => 150, item_name => 'P1_INPUT') which would return something like
    <input type="text" id="P1_INPUT" name="p_t04" class="text_field" value="" size="30" maxlength="4000">
    
    Is this possible?
    
    

    Sounds like an XY Problem.

    Why would you need to do this?

  • I need to create a "preview" of some components of a given APEX page.

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,427 Red Diamond
    vincent.morneau wrote:
    
    I need to create a "preview" of some components of a given APEX page.
    

    Still sounds like an XY Problem.

    Why do you need to create a "preview" of some components of a given APEX page?

  • I've got an application (X) that manages other applications within a Workspace.

    In order to extend it's visual capabilities, I want to reproduce the look and feel of a given APEX page inside my Application (X). I don't need it to have any functionality. Just look and feel.

    XY Problem or not (I don't think it is, it's just a unusual requirement), do you think it's doable?

    Thanks.

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,427 Red Diamond
    vincent.morneau wrote:
    
    I've got an application (X) that manages other applications within a Workspace.
    
    In order to extend it's visual capabilities, I want to reproduce the look and feel of a given APEX page inside my Application (X). I don't need it to have any functionality. Just look and feel.
    
    XY Problem or not (I don't think it is, it's just a unusual requirement)
    

    The original idea of retrieving HTML for individual components certainly is as far creating a visual preview is concerned. Without the complete HTML for the page and the CSS and images it references, just capturing component HTML and putting it on a page in another application wouldn't "reproduce the look and feel of a given APEX page"—although It could possibly get close if app X and the others all use the same theme and templates. However the more significant problem is that having got those components onto the page, they become part of it, and APEX would then fall over trying to process them. See for a discussion about a similar requirement.

    do you think it's doable?
    

    Yes, but not in the way you originally suggested. There is no documented and supported API to generate the mark-up for APEX components. You have to get APEX to render the content, then retrieve it.

    See utl_http and httpURIType for ways to get web pages in PL/SQL and SQL. APEX has a URL region type for retrieving content from other sites. However, for the reasons given above, this is almost certainly not the way to go.

    By far the simplest and safest approach is to get some screen dump images from the applications, upload them and display them in application X. (Have you considered some kind of web thumbnail service/tool?)

    If security for application X and the other apps is based on a shared session cookie and sandboxing is fully supported in the browsers used, then the iframe technique described in the linked thread above would be feasible.

  • Thank you fac586.

    All the application I'm talking about would indeed have the same Theme / Templates etc. so CSS and images would not be a issue.

    I will look at your solutions and choose which one suits me best.

This discussion has been closed.