Remember Me
forgot your password?

Partial Page Rendering Using Hidden Iframe

Partial Page Rendering Using Hidden IFrame

Executive Summary:

Partial-page rendering removes the need for the whole web page to be refreshed as the result of a postback. Instead, only individual regions of the page that have changed are updated. As a result, users do not see the whole page reload with every postback, which makes user interaction with the Web page more seamless.
Developers that want to add such behaviors to their web pages are often faced with a difficult decision. All of these actions can be implemented using a very simple solution: by refreshing the entire page in response to the user interaction. However this solution is easy but not always desirable. The full page refresh can be slow, giving the user the impression that the application is unresponsive. Another option is to implement such actions using JavaScript (or other client-side scripting technologies). This results in faster response times, at the expense of more complex, less portable code. JavaScript may be a good choice for simple actions, such as updating an image. However, for more complicated actions, such as scrolling through data in a table, writing custom JavaScript code can be a very challenging undertaking.
This paper provides a solution which avoids the drawbacks of the full page refresh and custom JavaScript solutions. In this paper partial page rendering functionality provides the ability to re-render a limited portion of a page. As in the full page render solution, partial page rendering sends a request back to the application on the middle-tier to fetch the new contents. However, when partial page rendering is used to update the page, only the modified contents are sent back to the browser. This paper gives the solution using a hidden IFrame and simple JavaScript to merge the new contents back into the web page. The end result is that the page is updated without custom JavaScript code, and without the loss of context that typically occurs with a full page refresh.

Introduction:

Web pages typically support a variety of actions, such as entering and submitting form data and navigating to different pages. Many web pages also support another type of action, which is to allow the user to make modifications to the contents of the web page itself without actually navigating to a different page. Some examples of such actions include.
Clicking on a link could update an image on the same page. For example, an automobile configuration application might update an image of a car as the user chooses different options, such as the preferred color.
Selecting an item from a choice box might result in modifications to other fields on the same page. For example, selecting a car make might update the set of available car models that are displayed.
Clicking a link or selecting an item from a choice could be used to scroll to a new page of data in a table. Clicking a button in a table might add a new row to the table.
All of these actions are similar in that they result in the same page being re-rendered in a slightly different state. Ideally, these changes should be implemented as seemlessly as possible, so that the user does not experience a loss of context which could distract from the task at hand.
Partial page rendering can be implemented with very simple solution using a hidden IFrame and minimal JavaScript. Any part of the page can be partially rendered with using a div or table tags in HTML.

Page Elements That May Change During PPR:

•Re-Render Data: The same fields are redrawn but their data is updated. Examples include the Refresh Data action button, or recalculate totals in a table.
•Re-render Dependent Fields: Fields may be added, removed, or change sequence, and data may be updated. Examples include the Country choice list, which may display different address fields, and toggling between Simple and Advanced Search.
•Hide/Show Content: Both fields and data toggle in and out of view.

Page Elements That Do Not Change During PPR:

Some page elements are always associated with a page, regardless of the content displayed on the page.

As a general rule of thumb, elements above the page title (except message boxes) remain constant and do not change position, whereas elements in footer constant but may move up or down the page to accommodate changes to page content. The following elements never change when PPR is initiated:
• Branding
• Global buttons
• Tabs, Horizontal Navigation, SubTabs
• Locator elements: Breadcrumbs, Train, Next/Back Locator
• Quick links
• Page titles (first level header)
• Page footer
• Separator lines between the Tabs and Page Title
In most cases the following elements will also not change, other than moving up or down the page to accommodate changed elements. Nevertheless, in certain cases actions on the page may require them to be redrawn:
• Side Navigation, unless it contains a Hide/Show control.
• Subtabs
• Contextual information
• Page-level action/navigation buttons
• Page-level Instruction text
• Page-level Page stamps
• Page-level Key Notation
In all above scenarios this solution can be used to achieve the good performance and user interaction of the web pages.

Contexts in Which PPR Should Not Be Used:

When PPR is implemented correctly, it significantly improves application performance. When performance improvement is not possible with PPR, it should not be implemented, thus avoiding unnecessary code bloat, PPR can’t be used when navigating to another page (with a different title).

Partial Page Rendering Solution:

Solution provided to the Partial Page Rendering using simple hidden iframe and JavaScript, this can be used as a generalized solution to all the Partial Page Rendering scenarios.
Below is the main html (Table 1.1), which will have two buttons one is to show a simple table which will be generated by the server, and another button to remove the table.

[html]
[head]
[title] Main Document [/title]
[script language="JavaScript"]
[!--
function showTable() {
hiframe.location="./table.htm";
}
function removeTable() {
document.getElementById("tableId").innerHTML="";
}
//--]
[/script]
[/head]
[body]
[iframe id="hiframe" style="visibility:hidden;display:none"][/iframe]
[table]
[tr]
[td]Table::[/td]
[td][/td]
[/tr]
[tr]
[td colspan="2"][div id="tableId"][/div][/td]
[/tr]
[tr]
[td][input type="button" value="Show Table" onclick="showTable()"][/td]
[td][input type="button" value="Remove Table" onclick="removeTable()"][/td]
[/tr]
[/table]
[/body]
[/html]

Table 1.1

[iframe id="hiframe" style="visibility:hidden;display:none"][/iframe]
This iframe tag is used as target to the Partial Page Rendering Request.
The tag [input type="button" value="Show Table" onclick="showTable()"] gives the user action to get the contents of a table from the server, in this solution sample html is provided to render the table, which supposed to be generated by the server.
The tag [input type="button" value="Remove Table" onclick="removeTable()"] gives the user to remove the table from the user interface.
The JavaScript
function showTable() {
hiframe.location="./table.htm";
}
Is used to get the contents from the server, the line hiframe.location="./table.htm"; sends the GET request to the server, and as a response iframe gets the HTML.
If the requirement insists to send a POST request for Partial Page rendering Response, that can be achieved by setting the html form element target attribute as the name of hidden iframe.

The code for the post request looks like
[form method=”post” action=”/myaction” target=”hiframe”]

Partial Page Rendering Server Response:

Table 1.2 shows the sample response from the server for Partial Page Rendering. This response has the JavaScript code to transfer the HTML from hidden iframe to main page.

[html]
[head]
[script language="JavaScript"]
[!--
function iframeLoad() {
parent.document.getElementById("tableId").innerHTML = document.getElementById("tableId").innerHTML;
}
//--]
[/script]
[/head]
[body onload="iframeLoad()"]
[div id="tableId"]
[table]
[tr]
[td]1[/td]
[td]One[/td]
[/tr]
[tr]
[td]2[/td]
[td]Two[/td]
[/tr]
[/table]
[/div]
[/body]
[/html]

Table 1.2
The tag [div id="tableId"] encloses the content to transfer from hidden iframe to main page.
[table]
[tr]
[td]1[/td]
[td]One[/td]
[/tr]
[tr]
[td]2[/td]
[td]Two[/td]
[/tr]
[/table]
This is the content to show the table to user.

The code [body onload="iframeLoad()"] is used for triggering the action to transfer the content.

function iframeLoad() {
parent.document.getElementById("tableId").innerHTML = document.getElementById("tableId").innerHTML;
}

This JavaScript function does the transferring data from the hidden iframe to main page.
parent.document.getElementById("tableId").innerHTML This part refers to tag div html id in main page and this part document.getElementById("tableId").innerHTML refers the HTML of the Partial Page Response.

Conclusion:

Improve the user experience with Web pages that are richer, that are more responsive to user actions, and that behave like traditional client applications. Reduce full-page refreshes and avoid page flicker. Partial page rendering using iframe is a very simple solution.

References:
1. http://ajax.asp.net/docs/overview/PartialPageRenderingOverview.aspx
2. http://www.w3schools.com/htmldom/dom_obj_document.asp
3. http://www.w3schools.com/tags/tag_iframe.asp
4. http://www.oracle.com/technology/tech/blaf/specs/ppr.html
5. http://download-west.oracle.com/otn_hosted_doc/jdeveloper/904preview/uixhelp/uixdevguide/partialpage.html

Madhusudan Pagadala

Madhusudan Pagadala is working as a Senior Software Engineer at NetZero,UnitedOnline, Inc., located in WoodlandHills,California,USA. He has 9+ years experience in Web Technologies like J2EE, HTML, and JavaScript. He pursued Master of Technology in AeroSpace Engineering from the prestigious college IIT, Kharagpur-India.

Rate this Article: 5 / 5 stars - 29 vote(s)
Print Email Re-Publish

Add new Comment



Captcha

  • Latest Information Technology Articles
  • More from Madhusudan Pagadala

Examsoon 000-005 study questions

By: Adela1987 | 31/12/2009
Exam 000-005 Preparation from Examsoon braindumps include: After you purchase our product, we will offer free update in time for 90 days. 100% Pass Guaranteed at First Attempt Or Full Refund Immediate Download After Purchase Comprehensive questions with complete details Questions accompanied by exhibits Verified Answers Researched by Industry Experts Drag and Drop questions as experienced in the Examsoon Questions updated on regular basis These questions and answers are backed by

Examsoo ST0-052 practice exams

By: Adela1987 | 31/12/2009
Our ST0-052 practice exams and study questions are composed by current and active Information Technology experts, who use their experience in preparing you for your future in IT.

Pass4side ST0-052 exam dumps

By: Adela1987 | 31/12/2009
It is well known that ST0-052 exam test is the hot exam of Symantec certification. Pass4side offer you all the Q&A of the ST0-052 real test . It is the examination of the perfect combination and it will help you pass ST0-052 exam at the first time!

Pass4side 000-005 exam test

By: Adela1987 | 31/12/2009
Pass4side Practice Exams for IBM 000-005 are written to the highest standards of technical accuracy, using only certified subject matter experts and published authors for development.

Pass4side 000-973 exam Braindumps

By: Adela1987 | 31/12/2009
Pass4side IBM 000-973 Practice test that we can provide are based on the extensive research and real-world experiences from our online trainers, with over 10 years of IT and certification experience. 000-973 exam training, including 000-973 questions and answers feed into our customers.

Pass4side 000-114 practice exam

By: Adela1987 | 31/12/2009
Pass4side 000-114 can guarantee that combined with proper effort and 000-114 preparation methods, our 000-114 practice exam modules will certainly boost your chance of passing the 000-114 exam! We are strongly confident that you will pass your 000-114 exam the first time!

Examsoon 000-209 study material

By: Adela1987 | 31/12/2009
Examsoon is one of these informatory websites which is popular all over the world and is the choice of IT professionals round the globe. It is an excellent source of information on IT Certifications. Just your regular visit of the website frees you from your worries of knowing what is current and the latest regarding certifications by all the major IT companies. Examsoon works wonders for the IT professionals as it has much more than mere information on certifications. You can find study tips as

Examsoon 000-973 Training Tools

By: Adela1987 | 31/12/2009
Examsoon 000-973 Exam will provide you with exam simulation questions and actual answers that reflect the actual exam. These Examsoon IBM 000-973 simulation questions and answers provide you with the experience of taking the actual test. Examsoon 000-973 Exam is not just simulation questions and answers. They are your access to high technical expertise and accelerated learning capacity. Examsoon 000-973 questions have detailed explanations for every answer and thus ensures that you fully underst

Simple J2ee Model View Controller Type II Framework

By: Madhusudan Pagadala | 27/05/2007 | Information Technology
Application presents content to users in numerous pages containing various data. Also, the engineering team responsible for designing, implementing, and maintaining the application is composed of individuals with different skill sets. One of the major concerns with the web applications is the separation between the logics that deal with Presentation itself, the data to be presented and the one that controls flow of logic. It is as an answer to such concerns that the Model-View-Controller or MVC pattern was designed. This paper provides the solution to modularize the user interface functionality of a Web application so that individual parts can be easily modified, that is model view controller framework.

Submit Your Articles Free: Signup
Article Categories




Use of this web site constitutes acceptance of the Terms Of Use and Privacy Policy | User published content is licensed under a Creative Commons License.
Copyright © 2005-2008 Free Articles by ArticlesBase.com, All rights reserved. (1.80, 8, w3)