Ques: 37 How will you use the Tile layout in your struts
application?
Ans: To use a Tile, You need
to perform the following steps:
* Import the Tiles taglib
with the taglib directive.
* Use tiles:insert tag to
insert the Tile layout into the current page.
* Use tile:put tag to pass
string parameters.
* Use tiles:put tag to
pass parameter Tiles.
Ques: 38 How will you create the the JSP Tile definition?
Ans: Definitions specify
default parameters for Tile layouts. You can create definitions in JSP or XML.
To create a JSP Tile Definition, follow the following steps:
* Import the Tiles tag
library using the taglib directive.
* Ensure that the
definition is created only once using the logic:notPresent tag.
*
Define the definition with the tiles:definition tag and pass the JSP
that defines the Tile layout and the scope of the newly created definition.
* Define the default
parameters with the tiles:put tag.
Ques: 39 How will you use the the JSP Tile definition in your
struts application?
Ans: To use a Tile
definition, follow these steps:
* Import the Tiles taglib
with taglib directive.
* Include the JSP page
that creates the definition by using jsp:include.
* Use the tiles:insert
tag, but specify the definition bean name and scope instead of the Tile layout
page.
* Use the tiles:put
attribute to specify the title and content but not header and footer
parameters.
Ques: 40 Describe the scope of the Tile in the Struts application?
Ans: The Tiles framework
defines an additional scope called Tile scope. Like page scope, Tile scope is
more private than request scope. It allows the user of the Tile to pass
arguments (called parameters) to the TIle. Like a display function, it makes
the page callable.
Nested tiles do not share the same Tile scope as their parent. The
Tile scope of the current Tile is saved before the nested Tile is displayed;
after the nested Tile finishes, the parent's Tile scope is restored to the
request.
Ques: 41 What is the difference between the jsp:include tag
and tiles:insert tag?
Ans: The jsp:include tag
allows you to call a page and pass it to request parameters (jsp:param); the
tiles:insert tag is similar but more powerful. The tiles:insert allows you to
call a page and pass it sub-pages (called Tiles) and attributes. Tile
scope lets you pass variables that are available only to that Tile
layout.
Ans:
Code Repetition is reduced
Use of Tiles reduce the code repetition to a great extent.
Code repetition is bad but repetition of layout logic could be worst. Tiles
also handle this issue. As you have layout templates based on which all the
pages are combined, you don't need to repeat the code for layout. Other view components
are also reusable and can be used in the same application at other places
reducing the code repetition.
2. Low coupling between pages
Coupling is the degree of interactivity between two entities. It
is always suggested to minimize coupling between unrelated classes, packages,
and so on. Same principle is applied to view components. Tiles reduce the
coupling between unrelated view components.
3. High layout control
Tiles provide great layout control by providing layout templates.
4. I18N support for locale-specific loading
5. Dynamic Page building
Pages are built dynamically in tiles. You can control the page
view by configuring it through xml.
6. Elimination of duplicate and redundant information
Tiles eliminate the duplicate and redundant information in the
configuration file by providing Tiles inheritance.
7. Central location for view components
Tiles save definition of all the components at one place (in
tilesDef.xml) and hence can be modified easily when required.
0 comments:
Post a Comment