Monday, March 31, 2008

SRUTS INTERVIEW QUESTIONS




Q.What is Tiles-def.xml n validation.xml in Struts?


tiles-def.xmltiles-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:



2. validation.xmlThe 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 fileInside that definition, you specify the validations you want to apply to the Form Bean's
fields.Eg:



3. Resourcebundle.propertiesInstead 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.propertieserrors.registrationForm.name={0} Is an invalid name.In the
registrationForm.jsp



Output(in red color) : abc Is an invalid name ________________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. Reusability2. 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.________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.

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 their corresponding equalents in different desiredlanguages. 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 anynumber of Form Beans in this configuration file. Inside that definition, you specify the validationsyou 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.


>>Next>>


0 comments: