INTERVIEW QUESTIONS
J2EE
STRUTS
DETAILS
Question: What is the purpose of tiles-def.xml file, resourcebundle.properties file, validation.xml file?
Answer: 1. tiles-def.xml tiles-def.xml is used as a configuration file for an appliction during tiles development You can define the layout / header / footer / body content for your View. Eg:
<tiles-definitions> <definition name="siteLayoutDef" path="/layout/thbiSiteLayout.jsp"> <put name="title" value="Title of the page" /> <put name="header" value="/include/thbiheader.jsp" /> <put name="footer" value="/include/thbifooter.jsp" /> <put name="content" type="string"> Content goes here </put> </definition> </tiles-definitions> <tiles-definitions> <definition name="userlogin" extends="siteLayoutDef"> <put name="content" value="/dir/login.jsp" /> </definition> </tiles-definitions> 2. validation.xml The validation.xml file is used to declare sets of validations that should be applied to Form Beans. Each Form Bean you want to validate has its own definition in this file Inside that definition, you specify the validations you want to apply to the Form Bean's fields. Eg:
<form-validation> <formset> <form name="logonForm"> <field property="username" depends="required"> <arg0 key=" prompt.username"/> </field> <field property="password" depends="required"> <arg0 key="prompt.password"/> </field> </form> </formset> </form-validation> 3. Resourcebundle.properties Instead of having hard-coded error messages in the framework, Struts Validator allows you to specify a key to a message in the ApplicationResources.properties (or resourcebundle.properties) file that should be returned if a validation fails. Eg:
In ApplicationResources.properties errors.registrationForm.name={0} Is an invalid name. In the registrationForm.jsp <html:messages id="messages" property="name"> <font color="red"> <bean:write name="messages" /> </html:messages> Output(in red color) : abc Is an invalid name Submitted by Krishnam R Lalisetti ([email protected])
________________
1. Purpose of tiles-def.xml file is used to in the design face of the webpage. For example in the webpage "top or bottom or left is fixed" center might be dynamically chaged. It is used for the easy design of the web sites. Reusability 2. resourcebundle.properties file is used for lot of purpose. One of its purpose is internationalization. We can make our page to view on any language. It is independent of it. Just based on the browser setting it selects the language and it displayed as you mentioned in the resourcebundle.properties file. 3. Validation rule.xml is used to put all the validation of the front-end in the validationrule.xml. So it verifies. If the same rule is applied in more than one page. No need to write the code once again in each page. Use validation to chek the errors in forms.
Submitted by R.Eswaramoorthy ([email protected])
_____________
tiles-def.xml - is required if your application incorporates the tiles framework in the "View" part of MVC. Generally we used to have a traditional JSP's (Which contgains HTML & java scriplets) are used in view. But Tiles is an advanced (mode or less ) implementation of frames used in HTML. We used to define the frames in HTML to seperate the header html, footer html, menu or left tree and body.html to reuse the contents. Hence in the same way, Tiles are defined to reuse the jsp's in struts like architectures, and we can define the jsp's which all are to be display at runtime, by providing the jsp names at runtime. To incorporate this we need tile-def.xml and the Class generally which extends RequestProcessor should extend TilesRequestProcessor. resourcebundle.properties -- It is to incorporate i18n (internationalization) in View part of MVC. validation.xml - This file is responsible for business validations carried at server side before processing the request actually. It reduces the complexity in writing _JavaScript validations, and in this way, we can hide the validations from the user, in View of MVC.
Submitted by Sagar GV ([email protected])
____________________
1.The Tiles Framework is an advanced version of that comes bundled with the Struts Webapp framework. Its purpose is reduce the duplication between jsp pages as well as make layouts flexible and easy to maintain. It integrates with Struts using the concept of named views or definitions.
2.Resourcebundle.properties is used to maintian all the strings that are used in the application and thier corresponding equalents in different desired languages. All the strings/labels in the application using Struts will get it labels from this file only depending on locale. This is an i18n implementation of struts
3. This validation.xml configuration file defines which validation routines that is used to validate Form Beans. You can define validation logic for any number of Form Beans in this configuration file. Inside that definition, you specify the validations you want to apply to the Form Bean's fields. The definitions in this file use the logical names of Form Beans from the struts-config.xml file along with the logical names of validation routines from the validator-rules.xml file to tie the two together.
Submitted by Binaya Patel ([email protected])
|
Question:
What is the purpose of tiles-def.xml file, resourcebundle.properties file, validation.xml file?
Answer:
1. tiles-def.xml tiles-def.xml is used as a configuration file for an appliction during tiles development You can define the layout / header / footer / body content for your View. Eg:
<tiles-definitions> <definition name="siteLayoutDef" path="/layout/thbiSiteLayout.jsp"> <put name="title" value="Title of the page" /> <put name="header" value="/include/thbiheader.jsp" /> <put name="footer" value="/include/thbifooter.jsp" /> <put name="content" type="string"> Content goes here </put> </definition> </tiles-definitions> <tiles-definitions> <definition name="userlogin" extends="siteLayoutDef"> <put name="content" value="/dir/login.jsp" /> </definition> </tiles-definitions> 2. validation.xml The validation.xml file is used to declare sets of validations that should be applied to Form Beans. Each Form Bean you want to validate has its own definition in this file Inside that definition, you specify the validations you want to apply to the Form Bean's fields. Eg:
<form-validation> <formset> <form name="logonForm"> <field property="username" depends="required"> <arg0 key=" prompt.username"/> </field> <field property="password" depends="required"> <arg0 key="prompt.password"/> </field> </form> </formset> </form-validation> 3. Resourcebundle.properties Instead of having hard-coded error messages in the framework, Struts Validator allows you to specify a key to a message in the ApplicationResources.properties (or resourcebundle.properties) file that should be returned if a validation fails. Eg:
In ApplicationResources.properties errors.registrationForm.name={0} Is an invalid name. In the registrationForm.jsp <html:messages id="messages" property="name"> <font color="red"> <bean:write name="messages" /> </html:messages> Output(in red color) : abc Is an invalid name Submitted by Krishnam R Lalisetti ([email protected])
________________
1. Purpose of tiles-def.xml file is used to in the design face of the webpage. For example in the webpage "top or bottom or left is fixed" center might be dynamically chaged. It is used for the easy design of the web sites. Reusability 2. resourcebundle.properties file is used for lot of purpose. One of its purpose is internationalization. We can make our page to view on any language. It is independent of it. Just based on the browser setting it selects the language and it displayed as you mentioned in the resourcebundle.properties file. 3. Validation rule.xml is used to put all the validation of the front-end in the validationrule.xml. So it verifies. If the same rule is applied in more than one page. No need to write the code once again in each page. Use validation to chek the errors in forms.
Submitted by R.Eswaramoorthy ([email protected])
_____________
tiles-def.xml - is required if your application incorporates the tiles framework in the "View" part of MVC. Generally we used to have a traditional JSP's (Which contgains HTML & java scriplets) are used in view. But Tiles is an advanced (mode or less ) implementation of frames used in HTML. We used to define the frames in HTML to seperate the header html, footer html, menu or left tree and body.html to reuse the contents. Hence in the same way, Tiles are defined to reuse the jsp's in struts like architectures, and we can define the jsp's which all are to be display at runtime, by providing the jsp names at runtime. To incorporate this we need tile-def.xml and the Class generally which extends RequestProcessor should extend TilesRequestProcessor. resourcebundle.properties -- It is to incorporate i18n (internationalization) in View part of MVC. validation.xml - This file is responsible for business validations carried at server side before processing the request actually. It reduces the complexity in writing _JavaScript validations, and in this way, we can hide the validations from the user, in View of MVC.
Submitted by Sagar GV ([email protected])
____________________
1.The Tiles Framework is an advanced version of that comes bundled with the Struts Webapp framework. Its purpose is reduce the duplication between jsp pages as well as make layouts flexible and easy to maintain. It integrates with Struts using the concept of named views or definitions.
2.Resourcebundle.properties is used to maintian all the strings that are used in the application and thier corresponding equalents in different desired languages. All the strings/labels in the application using Struts will get it labels from this file only depending on locale. This is an i18n implementation of struts
3. This validation.xml configuration file defines which validation routines that is used to validate Form Beans. You can define validation logic for any number of Form Beans in this configuration file. Inside that definition, you specify the validations you want to apply to the Form Bean's fields. The definitions in this file use the logical names of Form Beans from the struts-config.xml file along with the logical names of validation routines from the validator-rules.xml file to tie the two together.
Submitted by Binaya Patel ([email protected]) Source: CoolInterview.com
Tiles Framework is one of the advanced framework which reduces the replication in JSP Codes. Suppose we have an application where Page should display with some header (Logo of the company, welcome message if user is logged in), vertical menu (like available products as links), body part(product details once user clicks on product link of vertical menu), footer (licence info, contact links etc), then tiles helps us to have a common header jsp, vertical menu jsp, footer jsp and different body.jsps for each product and allows to merge them seperately with one name. Tiles-def.xml is a configuration file used to merge the JSPs with one common name.
Validation.xml : Validation framework allows user to validate the input data before performing the business logic. We have two configuration files in validation framework, they are
Validation-rules.xml Validation.xml
User can declare more than one validation.xml in sdingle applicaiton based on the requirement (like suppose u have 3 modules in appln, then u can create 3 different validation.xmls, one for each module). Validation-rules.xml helps the user to declare the common predefined values and common validators and based on these validation-rules.xml, user can write his own validation.xmls for each form.
Application resources.properties: Struts supports internationalization, where based on the locale value lables in the page may vary(like English in US, french in france etc). This can be implemented with application resources.properties file where resource file for each locale and system loads the reource properties based on the locale value.
Source: CoolInterview.com
Answered by: Venu | Date: 12/28/2009
| Contact Venu
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|