Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
book-of-vaadin.pdf
Скачиваний:
88
Добавлен:
24.03.2015
Размер:
13.43 Mб
Скачать

Advanced Web Application Topics

/* The UI Configuration */ vaadin.initApplication("helloworld", {

"browserDetailsUrl": "helloworld", "widgetset": "com.example.MyWidgetSet", "theme": "mytheme",

"versionInfo": {"vaadinVersion": "7.0.0"}, "vaadinDir": "VAADIN/", "heartbeatInterval": 300,

"debug": true, "standalone": false, "authErrMsg": {

"message": "Take note of any unsaved data, "+ "and <u>click here<\/u> to continue.",

"caption": "Authentication problem"

}, "comErrMsg": {

"message": "Take note of any unsaved data, "+ "and <u>click here<\/u> to continue.",

"caption": "Communication problem"

}, "sessExpMsg": {

"message": "Take note of any unsaved data, "+ "and <u>click here<\/u> to continue.",

"caption": "Session Expired"

}

});//]] > </script>

<p>Please view the page source to see how embedding works.</p> </body>

</html>

11.2.2. Embedding Inside an iframe Element

Embedding a Vaadin UI inside an <iframe> element is even easier than the method described above, as it does not require definition of any Vaadin specific definitions.

You can embed an UI with an element such as the following:

<iframe src="/myapp/myui"></iframe>

The <iframe> elements have several downsides for embedding. One is that their size of is not flexible depending on the content of the frame, but the content must be flexible to accommodate in the frame. You can set the size of an <iframe> element with height and width attributes. Other issues arise from themeing and communication with the frame content and the rest of the page.

Below is a complete example of using the <iframe> to embed two applications in a web page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" > <head>

<title>Embedding in IFrame</title> </head>

<body style="background: #d0ffd0;"> <h1>This is a HTML page</h1>

<p>Below are two Vaadin applications embedded inside a table:</p>

<table align="center" border="3"> <tr>

<th>The Calculator</th>

Embedding Inside an iframe Element

285

Advanced Web Application Topics

<th>The Color Picker</th> </tr>

<tr valign="top"> <td>

<iframe src="/vaadin-examples/Calc" height="200" width="150" frameborder="0"></iframe>

</td>

<td>

<iframe src="/vaadin-examples/colorpicker" height="330" width="400" frameborder="0"></iframe>

</td>

</tr>

</table>

</body>

</html>

The page will look as shown in Figure 11.2, “Vaadin Applications Embedded Inside IFrames” below.

Figure 11.2. Vaadin Applications Embedded Inside IFrames

You can embed almost anything in an iframe, which essentially acts as a browser window. However, this creates various problems. The iframe must have a fixed size, inheritance of CSS from the embedding page is not possible, and neither is interaction with JavaScript, which makes mashups impossible, and so on. Even bookmarking with URI fragments will not work.

Note also that websites can forbid iframe embedding by specifying an X-Frame-Options: SAMEORIGIN header in the HTTP response.

286

Embedding Inside an iframe Element

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]