This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Is Attribute Oriented Programming? |
|
Answer» XDoclet has brought the concept of attribute-oriented programming to Java. Until JDK 1.5, the Java language had no support for ANNOTATIONS; now XDoclet uses the Javadoc tag FORMAT (@attribute) to SPECIFY class-, field-, or method-level metadata attributes. These attributes are used to generate hibernate mapping file automatically when the application is built. This KIND of programming that WORKS on attributes is called as Attribute Oriented Programming. XDoclet has brought the concept of attribute-oriented programming to Java. Until JDK 1.5, the Java language had no support for annotations; now XDoclet uses the Javadoc tag format (@attribute) to specify class-, field-, or method-level metadata attributes. These attributes are used to generate hibernate mapping file automatically when the application is built. This kind of programming that works on attributes is called as Attribute Oriented Programming. |
|
| 2. |
What Is Hql? |
|
Answer» HQL STANDS for Hibernate QUERY Language. Hibernate allows the USER to express queries in its own portable SQL extension and this is called as HQL. It ALSO allows the user to express in native SQL. HQL stands for Hibernate Query Language. Hibernate allows the user to express queries in its own portable SQL extension and this is called as HQL. It also allows the user to express in native SQL. |
|
| 3. |
What Is Object/relational Mapping Metadata? |
|
Answer» ORM tools require a metadata format for the APPLICATION to SPECIFY the mapping between classes and tables, properties and columns, associations and foreign keys, Java types and SQL types. This information is called the object/relational mapping metadata. It defines the TRANSFORMATION between the different data type SYSTEMS and relationship representations. ORM tools require a metadata format for the application to specify the mapping between classes and tables, properties and columns, associations and foreign keys, Java types and SQL types. This information is called the object/relational mapping metadata. It defines the transformation between the different data type systems and relationship representations. |
|
| 4. |
What Are Pojos? |
|
Answer» POJO stands for plain old java objects. These are just basic JAVABEANS that have DEFINED SETTER and getter methods for all the properties that are there in that bean. Besides they can also have some business logic related to that property. Hibernate applications works efficiently with POJOS RATHER then simple java classes. POJO stands for plain old java objects. These are just basic JavaBeans that have defined setter and getter methods for all the properties that are there in that bean. Besides they can also have some business logic related to that property. Hibernate applications works efficiently with POJOs rather then simple java classes. |
|
| 5. |
What Should Sessionfactory Be Placed So That It Can Be Easily Accessed? |
|
Answer» As far as it is compared to J2EE environment, if the SESSIONFACTORY is PLACED in JNDI then it can be easily ACCESSED and SHARED between different threads and various components that are hibernate aware. You can set the SessionFactory to a JNDI by configuring a property hibernate. session_ factory_ name in the hibernate. properties file. As far as it is compared to J2EE environment, if the SessionFactory is placed in JNDI then it can be easily accessed and shared between different threads and various components that are hibernate aware. You can set the SessionFactory to a JNDI by configuring a property hibernate. session_ factory_ name in the hibernate. properties file. |
|
| 6. |
What Does Hibernate.properties File Consist Of? |
|
Answer» This is a property file that should be PLACED in application CLASS path. So when the Configuration object is created, hibernate is first initialized. At this MOMENT the application will AUTOMATICALLY detect and read this hibernate.properties file. This is a property file that should be placed in application class path. So when the Configuration object is created, hibernate is first initialized. At this moment the application will automatically detect and read this hibernate.properties file. |
|
| 7. |
What Is Meant By Method Chaining? |
|
Answer» METHOD chaining is a programming technique that is supported by many hibernate interfaces. This is LESS READABLE when COMPARED to actual java code. And it is not mandatory to use this format. Look how a SESSIONFACTORY is created when we use method chaining. SessionFactory sessions = new Configuration() Method chaining is a programming technique that is supported by many hibernate interfaces. This is less readable when compared to actual java code. And it is not mandatory to use this format. Look how a SessionFactory is created when we use method chaining. SessionFactory sessions = new Configuration() |
|
| 8. |
What Do You Create A Sessionfactory? |
|
Answer» Configuration cfg = new Configuration(); Configuration cfg = new Configuration(); |
|
| 9. |
What Is The File Extension You Use For Hibernate Mapping File? |
|
Answer» The NAME of the FILE should be like this : filename.hbm.xml The name of the file should be like this : filename.hbm.xml |
|
| 10. |
What Are Different Environments To Configure Hibernate? |
|
Answer» There are mainly TWO types of environments in which the configuration of hibernate application differs. There are mainly two types of environments in which the configuration of hibernate application differs. |
|
| 11. |
What Are The Extension Interfaces That Are There In Hibernate? |
|
Answer» There are many extension interfaces PROVIDED by hibernate. There are many extension interfaces provided by hibernate. |
|
| 12. |
What Are Extension Interfaces? |
|
Answer» When the built-in FUNCTIONALITIES PROVIDED by HIBERNATE is not sufficient enough, itprovides a way so that user can include other INTERFACES and implement those interfaces for user desire functionality. These interfaces are called as Extension interfaces. When the built-in functionalities provided by hibernate is not sufficient enough, itprovides a way so that user can include other interfaces and implement those interfaces for user desire functionality. These interfaces are called as Extension interfaces. |
|
| 13. |
What Are Callback Interfaces? |
|
Answer» These interfaces are used in the application to receive a notification when some OBJECT events occur. Like when an object is loaded, saved or DELETED. There is no need to IMPLEMENT callbacks in hibernate APPLICATIONS, but they’re useful for implementing certain KINDS of generic functionality. These interfaces are used in the application to receive a notification when some object events occur. Like when an object is loaded, saved or deleted. There is no need to implement callbacks in hibernate applications, but they’re useful for implementing certain kinds of generic functionality. |
|
| 14. |
What The Core Interfaces Are Of Hibernate Framework? |
|
Answer» There are many benefits from these. Out of which the FOLLOWING are the most important one. i. Session INTERFACE – This is the primary interface used by hibernate applications. The instances of this interface are lightweight and are INEXPENSIVE to create and DESTROY. Hibernate sessions are not thread safe. There are many benefits from these. Out of which the following are the most important one. i. Session Interface – This is the primary interface used by hibernate applications. The instances of this interface are lightweight and are inexpensive to create and destroy. Hibernate sessions are not thread safe. |
|
| 15. |
What Is A Hibernate Xml Mapping Document And How Does It Look Like? |
|
Answer» In order to make most of the things work in hibernate, usually the information is provided in an xml document. This document is called as xml mapping document. The document defines, among other things, how properties of the user defined persistence classes’ map to the columns of the RELATIVE tables in database. <?xml VERSION="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC In order to make most of the things work in hibernate, usually the information is provided in an xml document. This document is called as xml mapping document. The document defines, among other things, how properties of the user defined persistence classes’ map to the columns of the relative tables in database. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC |
|
| 16. |
How Does Hibernate Code Looks Like? |
|
Answer» Session session = getSessionFactory().openSession(); Session session = getSessionFactory().openSession(); |
|
| 17. |
What Are The Benefits Of Orm And Hibernate? |
|
Answer» There are many benefits from these. Out of which the following are the most important one. There are many benefits from these. Out of which the following are the most important one. |
|
| 18. |
What Is Meant By Full Object Mapping? |
|
Answer» Full object mapping supports sophisticated object modeling: composition, INHERITANCE, polymorphism and persistence. The persistence layer implements transparent persistence; persistent classes do not inherit any SPECIAL base class or have to implement a special interface. Efficient fetching strategies and caching strategies are IMPLEMENTED transparently to the application. Full object mapping supports sophisticated object modeling: composition, inheritance, polymorphism and persistence. The persistence layer implements transparent persistence; persistent classes do not inherit any special base class or have to implement a special interface. Efficient fetching strategies and caching strategies are implemented transparently to the application. |
|
| 19. |
What Is A Meant By Medium Object Mapping? |
|
Answer» The application is DESIGNED around an object model. The SQL CODE is generated at build time. And the associations between objects are supported by the persistence MECHANISM, and queries are specified using an object-oriented expression language. This is best suited for medium-sized applications with some complex transactions. Used when the mapping exceeds 25 different DATABASE products at a time. The application is designed around an object model. The SQL code is generated at build time. And the associations between objects are supported by the persistence mechanism, and queries are specified using an object-oriented expression language. This is best suited for medium-sized applications with some complex transactions. Used when the mapping exceeds 25 different database products at a time. |
|
| 20. |
What Is A Meant By Light Object Mapping? |
|
Answer» The entities are REPRESENTED as classes that are mapped MANUALLY to the relational tables. The code is hidden from the business logic USING specific DESIGN PATTERNS. This approach is successful for applications with a less number of entities, or applications with common, metadata-driven data models. This approach is most known to all. The entities are represented as classes that are mapped manually to the relational tables. The code is hidden from the business logic using specific design patterns. This approach is successful for applications with a less number of entities, or applications with common, metadata-driven data models. This approach is most known to all. |
|
| 21. |
What Is A Pure Relational Orm? |
|
Answer» The entire APPLICATION, including the USER INTERFACE, is DESIGNED around the relational MODEL and SQL-based relational operations. The entire application, including the user interface, is designed around the relational model and SQL-based relational operations. |
|
| 22. |
What Are The Different Levels Of Orm Quality? |
|
Answer» There are four levels defined for ORM quality. There are four levels defined for ORM quality. |
|
| 23. |
What Does An Orm Solution Comprises Of? |
|
Answer» • It should have an API for performing basic CRUD (CREATE, Read, Update, DELETE) operations on objects of persistent classes. • It should have an API for performing basic CRUD (Create, Read, Update, Delete) operations on objects of persistent classes. |
|
| 24. |
What Is Orm? |
|
Answer» ORM stands for Object/Relational mapping. It is the programmed and translucent PERSEVERANCE of OBJECTS in a Java application in to the tables of a relational database using the metadata that describes the mapping between the objects and the database. It WORKS by transforming the data from one representation to ANOTHER. ORM stands for Object/Relational mapping. It is the programmed and translucent perseverance of objects in a Java application in to the tables of a relational database using the metadata that describes the mapping between the objects and the database. It works by transforming the data from one representation to another. |
|
| 25. |
What Is Hibernate? |
|
Answer» Hibernate is a powerful, high performance object/relational persistence and query service. This lets the USERS to develop persistent classes following object-oriented principles such as ASSOCIATION, inheritance, POLYMORPHISM, COMPOSITION, and collections. Hibernate is a powerful, high performance object/relational persistence and query service. This lets the users to develop persistent classes following object-oriented principles such as association, inheritance, polymorphism, composition, and collections. |
|
| 26. |
Declarative Exception Handling |
|
Answer» If you have developed web applications long enough, you will realize a recurring pattern emerges: when the backend (e.g. the EJB TIER) throws you an exception, you nearly always need to display an error page corresponding to the type of that exception. Sooner or later, you will come up with a mechanism to use a lookup table (e.g. an HashMap) to lookup an error page from the exception class. Struts 1.1 now provides a similar but more powerful mechanism to declare exception HANDLING. In Struts 1.1, you can declare in the struts-config.xml the ASSOCIATIONS between an exception class and an exception HANDLER. Using the default exception handler included in Struts, you can also specify the path of the error pages. With this INFORMATION, Struts will automatically forward to the specified pages when an uncaught exception is thrown from an Action. Like other facilities in Struts, the exception handlers are pluggable. You can write and define your own handler classes if needed. If you have developed web applications long enough, you will realize a recurring pattern emerges: when the backend (e.g. the EJB tier) throws you an exception, you nearly always need to display an error page corresponding to the type of that exception. Sooner or later, you will come up with a mechanism to use a lookup table (e.g. an HashMap) to lookup an error page from the exception class. Struts 1.1 now provides a similar but more powerful mechanism to declare exception handling. In Struts 1.1, you can declare in the struts-config.xml the associations between an exception class and an exception handler. Using the default exception handler included in Struts, you can also specify the path of the error pages. With this information, Struts will automatically forward to the specified pages when an uncaught exception is thrown from an Action. Like other facilities in Struts, the exception handlers are pluggable. You can write and define your own handler classes if needed. |
|
| 27. |
How Can I Avoid Validating A Form Before Data Is Entered? |
|
Answer» The simplest way is to have two actions. The first one has the job of setting the form data, i.e. a blank registration screen. The second action in our WRITES the registration data to the database. Struts would take care of invoking the VALIDATION and returning the user to the correct screen if validation was not COMPLETE. The EditRegistration action in the struts example application illustrates this: < action path="/editRegistration"> When the /editRegistration action is invoked, a registrationForm is created and added to the request, but its validate method is not called. The default value of the validate attribute is true, so if you do not want an action to trigger form validation, you need to remember to add this attribute and set it to false. The simplest way is to have two actions. The first one has the job of setting the form data, i.e. a blank registration screen. The second action in our writes the registration data to the database. Struts would take care of invoking the validation and returning the user to the correct screen if validation was not complete. The EditRegistration action in the struts example application illustrates this: < action path="/editRegistration"> When the /editRegistration action is invoked, a registrationForm is created and added to the request, but its validate method is not called. The default value of the validate attribute is true, so if you do not want an action to trigger form validation, you need to remember to add this attribute and set it to false. |
|
| 28. |
When Is The Best Time To Validate Input? |
|
Answer» This is an excellent question. Let's step back a second and think about a typical mid to large size application. If we start from the back end and work TOWARD the view we have: This is an excellent question. Let's step back a second and think about a typical mid to large size application. If we start from the back end and work toward the view we have: |
|
| 29. |
Can You Give Me A Simple Example Of Using The Requiredif Validator Rule? |
|
Answer» First off, there's an even newer Validator RULE called validwhen, which is almost certainly what you want to USE, since it is much easier and more powerful. It will be available in the first release after 1.1 ships. First off, there's an even newer Validator rule called validwhen, which is almost certainly what you want to use, since it is much easier and more powerful. It will be available in the first release after 1.1 ships. |
|
| 30. |
Can I Have An Action Without A Form? |
|
Answer» Yes. If your Action does not need any data and it does not need to make any data available to the view or controller component that it forwards to, it doesn't need a form. A good example of an Action with no ActionForm is the LogoffAction in the struts example application: <action path="/logoff" However, you cannot use the <html:form> tag without an ActionForm. Even if you want to use the <html:form> tag with a simple Action that does not REQUIRE input, the tag will expect you to use some type of ActionForm, even if it is an empty subclass without any properties. Yes. If your Action does not need any data and it does not need to make any data available to the view or controller component that it forwards to, it doesn't need a form. A good example of an Action with no ActionForm is the LogoffAction in the struts example application: <action path="/logoff" However, you cannot use the <html:form> tag without an ActionForm. Even if you want to use the <html:form> tag with a simple Action that does not require input, the tag will expect you to use some type of ActionForm, even if it is an empty subclass without any properties. |
|
| 31. |
Do I Have To Use Jsps With My Application? |
|
Answer» The short answer to this question is: No, you are not limited to JavaServer PAGES. The short answer to this question is: No, you are not limited to JavaServer Pages. |
|
| 32. |
Why Does The Option Tag Render Selected=selected Instead Of Just Selected? |
|
Answer» Attribute minimization (that is, specifying an attribute with no value) is a place where HTML violates standard XML syntax RULES. This matters a lot for people WRITING to BROWSERS that support XHTML, where doing so makes the page invalid. It's much better for STRUTS to use the expanded syntax, which works the same on existing browsers interpreting HTML, and newer browsers that EXPECT XHTML-compliant syntax. Struts is following the behavior recommended by the XHTML specification. Attribute minimization (that is, specifying an attribute with no value) is a place where HTML violates standard XML syntax rules. This matters a lot for people writing to browsers that support XHTML, where doing so makes the page invalid. It's much better for Struts to use the expanded syntax, which works the same on existing browsers interpreting HTML, and newer browsers that expect XHTML-compliant syntax. Struts is following the behavior recommended by the XHTML specification. |
|
| 33. |
Why Does The Tag Url-encode Javascript And Mailto Links? |
|
Answer» The <html:link> tag is not intended for USE with client-side references like those used to launch Javascripts or email CLIENTS. The purpose of link tag is to interject the context (or module) path into the URI so that your server-side links are not dependent on your context (or module) NAME. It also encodes the link, as needed, to maintain the client's SESSION on the server. Neither feature applies to client-side links, so there is no reason to use the <html:link> tag. Simply markup the client-side links using the standard tag. The <html:link> tag is not intended for use with client-side references like those used to launch Javascripts or email clients. The purpose of link tag is to interject the context (or module) path into the URI so that your server-side links are not dependent on your context (or module) name. It also encodes the link, as needed, to maintain the client's session on the server. Neither feature applies to client-side links, so there is no reason to use the <html:link> tag. Simply markup the client-side links using the standard tag. |
|
| 34. |
Why Do The Struts Tags Provide For So Little Formatting? |
|
Answer» The Struts tags seem to provide only the most rudimentary functionality. Why is there not better support for date formatting and advanced string handling? Three reasons: First, work started on the JSTL and we didn't want to duplicate the effort. Third, in a Model 2 application, most of the formatting can be HANDLED in the ActionForms (or in the business tier), so all the tag has to do is SPIT out a string. This leads to better reuse since the same "how to format" code does not need to be repeated in every INSTANCE. You can "say it once" in a JavaBean and be done with it. Why don't the Struts taglibs offer more layout options? Since the Struts tags are open source, you can extend them to provide whatever ADDITIONAL formatting you may need. If you are interested in a pre-written taglib that offers more layout options, see the struts-layout taglib. In the same arena, there is a well regarded CONTRIBUTOR taglib that can help you create Menus for your Struts applications. The Struts tags seem to provide only the most rudimentary functionality. Why is there not better support for date formatting and advanced string handling? Three reasons: First, work started on the JSTL and we didn't want to duplicate the effort. Third, in a Model 2 application, most of the formatting can be handled in the ActionForms (or in the business tier), so all the tag has to do is spit out a string. This leads to better reuse since the same "how to format" code does not need to be repeated in every instance. You can "say it once" in a JavaBean and be done with it. Why don't the Struts taglibs offer more layout options? Since the Struts tags are open source, you can extend them to provide whatever additional formatting you may need. If you are interested in a pre-written taglib that offers more layout options, see the struts-layout taglib. In the same arena, there is a well regarded contributor taglib that can help you create Menus for your Struts applications. |
|
| 35. |
How Can I Scroll Through List Of Pages Like The Search Results In Google? |
|
Answer» MANY Struts DEVELOPERS USE the Pager from the JSPTags SITE. Many Struts developers use the Pager from the JSPTags site. |
|
| 36. |
Can I Use Javascript To Submit A Form? |
|
Answer» You can submit a form with a link as below. BTW, the examples below assume you are in an block and 'myForm' is picked up from the struts-config.xml name field of the action. <a href='javascript:void(document.forms["myForm"].submit()>My Link</a> This is just one of many WAYS to achieve submitting a form and decoding the INTENDED action. Once you get used to the framework you will find other ways that make more sense for your coding style and requirements. Just remember this example is completely non-functional without JavaScript. You can submit a form with a link as below. BTW, the examples below assume you are in an block and 'myForm' is picked up from the struts-config.xml name field of the action. <a href='javascript:void(document.forms["myForm"].submit()>My Link</a> This is just one of many ways to achieve submitting a form and decoding the intended action. Once you get used to the framework you will find other ways that make more sense for your coding style and requirements. Just remember this example is completely non-functional without JavaScript. |
|
| 37. |
Can't I Just Create Some Of My Javabeans In The Jsp Using A Scriptlet? |
|
Answer» Struts is designed to encourage a MODEL 2/MVC architecture. But there is nothing that prevents you from using Model 1 techniques in your JavaServer Pages, so the answer to the question is "Yes, you can". Though, using Model 1 techniques in a Struts application does go against the grain. The approach recommended by most Struts developers is to create and populate whatever objects the view may need in the Action, and then forward these through the request. Some objects may also be created and stored in the session or context, depending on how they are used. Likewise, there is nothing to prevent you from using scriptlets along with JSP tags in your pages. Though, many Struts developers report writing very complex scriplet-free applications and recommend the JSP tag approach to OTHERS. For HELP with Model 1 techniques and scriptlets, you might consider joining the Javasoft JSP-interest mailing list, where there are more people still using these approaches. Struts is designed to encourage a Model 2/MVC architecture. But there is nothing that prevents you from using Model 1 techniques in your JavaServer Pages, so the answer to the question is "Yes, you can". Though, using Model 1 techniques in a Struts application does go against the grain. The approach recommended by most Struts developers is to create and populate whatever objects the view may need in the Action, and then forward these through the request. Some objects may also be created and stored in the session or context, depending on how they are used. Likewise, there is nothing to prevent you from using scriptlets along with JSP tags in your pages. Though, many Struts developers report writing very complex scriplet-free applications and recommend the JSP tag approach to others. For help with Model 1 techniques and scriptlets, you might consider joining the Javasoft JSP-interest mailing list, where there are more people still using these approaches. |
|
| 38. |
Why Are My Checkboxes Not Being Set From On To Off? |
|
Answer» A problem with a checkbox is that the browser will only include it in the request when it is checked. If it is not checked, the HTML specification SUGGESTS that it not be sent (i.e. omitted from the request). If the value of the checkbox is being persisted, either in a session bean or in the model, a checked box can never unchecked by a HTML FORM -- because the form can never send a signal to UNCHECK the box. The application must somehow ascertain that since the element was not sent that the corresponding value is unchecked. The recommended approach for Struts applications is to use the reset method in the ActionForm to set all properties represented by checkboxes to null or false. The checked boxes submitted by the form will then set those properties to true. The omitted properties will remain false. Another solution is to use radio buttons instead, which always submit a value. It is IMPORTANT to note that the HTML specification recommends this same behavior WHENEVER a control is not "successful". Any blank element in a HTML form is not guaranteed to submitted. It is therefor very important to set the default values for an ActionForm correctly, and to implement the reset method when the ActionForm might kept in session scope. A problem with a checkbox is that the browser will only include it in the request when it is checked. If it is not checked, the HTML specification suggests that it not be sent (i.e. omitted from the request). If the value of the checkbox is being persisted, either in a session bean or in the model, a checked box can never unchecked by a HTML form -- because the form can never send a signal to uncheck the box. The application must somehow ascertain that since the element was not sent that the corresponding value is unchecked. The recommended approach for Struts applications is to use the reset method in the ActionForm to set all properties represented by checkboxes to null or false. The checked boxes submitted by the form will then set those properties to true. The omitted properties will remain false. Another solution is to use radio buttons instead, which always submit a value. It is important to note that the HTML specification recommends this same behavior whenever a control is not "successful". Any blank element in a HTML form is not guaranteed to submitted. It is therefor very important to set the default values for an ActionForm correctly, and to implement the reset method when the ActionForm might kept in session scope. |
|
| 39. |
Why Doesn't The Focus Feature On The Tag Work In Every Circumstance? |
|
Answer» Unfortunately, there is some DISAGREEMENT between the various browsers, and different versions of the same browser, as to how the FOCUS can be SET. The <html:form> tag provides a QUICK and easy JavaScript that will set the focus on a form for most versions of most browsers. If this feature doesn't work for you, then you should set the focus using your own JavaScript. The focus feature is a convenient "value-add" -- not a CORE requirement of the tag. If you do come up with a JavaScript that provides the final solution to this project, please post your patch to this Bugzilla ticket. Unfortunately, there is some disagreement between the various browsers, and different versions of the same browser, as to how the focus can be set. The <html:form> tag provides a quick and easy JavaScript that will set the focus on a form for most versions of most browsers. If this feature doesn't work for you, then you should set the focus using your own JavaScript. The focus feature is a convenient "value-add" -- not a core requirement of the tag. If you do come up with a JavaScript that provides the final solution to this project, please post your patch to this Bugzilla ticket. |
|
| 40. |
Can I Use Multiple Html Form Elements With The Same Name? |
|
Answer» YES. Define the element as an array and Struts will autopopulate it like any other. Yes. Define the element as an array and Struts will autopopulate it like any other. |
|
| 41. |
Do Actionforms Have To Be True Javabeans? |
|
Answer» The UTILITIES that Struts uses (Commons-BeanUtils since 1.1) require that ACTIONFORM properties follow the JavaBean patterns for mutators and accessors (GET*,SET*,is*). Since Struts uses the Introspection API with the ActionForms, some containers may require that all the JavaBean patterns be followed, including declaring "implements Serializable" for each subclass. The safest thing is to review the JavaBean specification and follow all the prescribed patterns. Since Struts 1.1, you can also use DynaActionForms and mapped-backed forms, which are not TRUE JavaBeans. For more see ActionForm classes in the User Guide and Using Hashmaps with ActionForms in this FAQ. The utilities that Struts uses (Commons-BeanUtils since 1.1) require that ActionForm properties follow the JavaBean patterns for mutators and accessors (get*,set*,is*). Since Struts uses the Introspection API with the ActionForms, some containers may require that all the JavaBean patterns be followed, including declaring "implements Serializable" for each subclass. The safest thing is to review the JavaBean specification and follow all the prescribed patterns. Since Struts 1.1, you can also use DynaActionForms and mapped-backed forms, which are not true JavaBeans. For more see ActionForm classes in the User Guide and Using Hashmaps with ActionForms in this FAQ. |
|
| 42. |
Why Is Actionform A Base Class Rather Than An Interface? |
|
Answer» The MVC design pattern is very simple to understand but much more difficult to live with. You just need this little bit of BUSINESS Logic in the View logic or you need just that little bit of View logic in the Business tier and pretty SOON you have a real mess. Making ActionForm a class takes advantage of the single inheritance restriction of Java to it MAKES it more difficult for people to do things that they should not do. ActionForms implemented as interfaces encourage making the property types match the underlying business tier instead of Strings, which violates one of the PRIMARY purposes for ActionForms in the first place (the ability to reproduce invalid input, which is a fundamental user expectation). ActionForms as an interface would also encourage using existing DAO objects as ActionForms by adding implements ActionForm to the class. This violates the MVC design pattern goal of separation of the view and business logic. Since the goal of struts is to enforce this separation, it just makes more sense for Struts to own the ActionForm. DynaActionForms relieve developers of maintaining simple ActionForms. For near zero maintenance, TRY Niall Pemberton's LazyActionForm. The MVC design pattern is very simple to understand but much more difficult to live with. You just need this little bit of Business Logic in the View logic or you need just that little bit of View logic in the Business tier and pretty soon you have a real mess. Making ActionForm a class takes advantage of the single inheritance restriction of Java to it makes it more difficult for people to do things that they should not do. ActionForms implemented as interfaces encourage making the property types match the underlying business tier instead of Strings, which violates one of the primary purposes for ActionForms in the first place (the ability to reproduce invalid input, which is a fundamental user expectation). ActionForms as an interface would also encourage using existing DAO objects as ActionForms by adding implements ActionForm to the class. This violates the MVC design pattern goal of separation of the view and business logic. Since the goal of struts is to enforce this separation, it just makes more sense for Struts to own the ActionForm. DynaActionForms relieve developers of maintaining simple ActionForms. For near zero maintenance, try Niall Pemberton's LazyActionForm. |
|
| 43. |
Why Are Some Of The Class And Element Names Counter-intuitive? |
|
Answer» The framework grew in the telling and, as it EVOLVED, some of the names drifted. The good THING about a nightly build, is that everything BECOMES available to the COMMUNITY as soon as it is written. The bad thing about a nightly build is that things like class names get locked down early and then BECOME difficult to change. The framework grew in the telling and, as it evolved, some of the names drifted. The good thing about a nightly build, is that everything becomes available to the community as soon as it is written. The bad thing about a nightly build is that things like class names get locked down early and then become difficult to change. |
|
| 44. |
What Is A Modular Application? What Does Module-relative Mean? |
|
Answer» Since Struts 1.1, the framework supports multiple APPLICATION modules. All applications have at least one root, or default, module. Like the root directory in a file system, the default application has no NAME. (Or is named with an empty string, depending your viewpoint.) Developing an application with only a default module is no different from how applications were developed under Struts 1.0. Since Struts 1.1, you can add additional modules to your application, each of which can have their own CONFIGURATION FILES, messages resources, and so forth. Each module is developed in the same way as the default module. Applications that were developed as a single module can ADDED to a multiple module application, and modules can promoted to a standalone application without change. For more about configuring your application to support multiple modules, see Configuring Applications in the User Guide. But to answer the question =:0), a modular application is a Struts application that uses more than one module. Module-relative means that the URI starts at the module level, rather than at the context level, or the absolute-URL level. * Absolute URL: http://localhost/myApplication/myModule/myAction.do Since Struts 1.1, the framework supports multiple application modules. All applications have at least one root, or default, module. Like the root directory in a file system, the default application has no name. (Or is named with an empty string, depending your viewpoint.) Developing an application with only a default module is no different from how applications were developed under Struts 1.0. Since Struts 1.1, you can add additional modules to your application, each of which can have their own configuration files, messages resources, and so forth. Each module is developed in the same way as the default module. Applications that were developed as a single module can added to a multiple module application, and modules can promoted to a standalone application without change. For more about configuring your application to support multiple modules, see Configuring Applications in the User Guide. But to answer the question =:0), a modular application is a Struts application that uses more than one module. Module-relative means that the URI starts at the module level, rather than at the context level, or the absolute-URL level. * Absolute URL: http://localhost/myApplication/myModule/myAction.do |
|
| 45. |
Why Was Reload Removed From Struts (since 1.1)? |
|
Answer» The problem with ReloadAction was that Struts was trying to act like a container, but it couldn't do a proper job of it. For EXAMPLE, you can't reload classes that have been modified, or (portably) add new classes to a running web application (even if the container supported it). Meanwhile, as Struts 1.1 was being developed, work PROGRESSED on THINGS like Tomcat's reload command via the Manager webapp. This feature allows you to quickly reload-on-demand, complete with saving and restoring your SESSION). It started to make even less sense for Struts to half-implement a feature that containers are implementing fully. A more minor point is that freezing the configuration information at application startup time allows Struts to safely access the mapping information without bothering with synchronization. The "startup-only" strategy creates a modest but real improvement in performance for all users. So, ReloadAction is not supported since Struts 1.1 for two reasons: * It never did let you reload everything that you would really WANT to -- particularly changed classes -- so many people ended up having to reload the webapp anyway. Of course, if someone came up with an implementation that solved these problems without creating any others, we would not be opposed to including a new ReloadAction. The problem with ReloadAction was that Struts was trying to act like a container, but it couldn't do a proper job of it. For example, you can't reload classes that have been modified, or (portably) add new classes to a running web application (even if the container supported it). Meanwhile, as Struts 1.1 was being developed, work progressed on things like Tomcat's reload command via the Manager webapp. This feature allows you to quickly reload-on-demand, complete with saving and restoring your session). It started to make even less sense for Struts to half-implement a feature that containers are implementing fully. A more minor point is that freezing the configuration information at application startup time allows Struts to safely access the mapping information without bothering with synchronization. The "startup-only" strategy creates a modest but real improvement in performance for all users. So, ReloadAction is not supported since Struts 1.1 for two reasons: * It never did let you reload everything that you would really want to -- particularly changed classes -- so many people ended up having to reload the webapp anyway. Of course, if someone came up with an implementation that solved these problems without creating any others, we would not be opposed to including a new ReloadAction. |
|
| 46. |
Is There A Particularly Good Ide To Use With Struts? |
|
Answer» Struts should work well with any development environment that you WOULD like to use, as well as with any programmers EDITOR. The members of the Struts development TEAM each use their own tools such as EMACS, IDEA, Eclipse, and NETBEANS. Struts should work well with any development environment that you would like to use, as well as with any programmers editor. The members of the Struts development team each use their own tools such as Emacs, IDEA, Eclipse, and NetBeans. |
|
| 47. |
What About Jstl And Javaserver Faces ? |
|
Answer» JSTL, the JavaServer Standard Tag Library, is a set of JSP tags that are designed to make it easier to DEVELOP Web applications. JavaServer Faces (JSF) is a specification for a new technology that promises to make it easier to write MVC applications, both for the Web and for the desktop. The inventor of Struts, Craig McClanahan, is the specification co-lead for JavaServer Faces (JSR 127), and architect of the REFERENCE implemenation as well as Java Studio Creator. Both JSTL and JSF are complementary to Struts. The mainstay of the Struts framework is the controller components, which can be used with any Java presentation technology. As new technologies become available, it is certain that new "glue" components will also APPEAR to help these technologies work as well with Struts. Struts originally came bundled with a set of custom JSP tags. Today, several extensions are available to help you use Struts with other popular presentation technologies, like XSLT and VELOCITY. Likewise, extensions for JSTL and JSF are now available as well. The JSTL reference implementation is available through the Jakarta Taglibs site. A JSTL taglibs for Struts, Struts-El , is available and distributed with Struts beginning with the 1.1 release. The JSF specification and reference implementation is available through Sun's The JSF specification and reference implementation is available through Sun's Java ServerFaces page. An early-release JavaServer Faces taglib for Struts, Struts-Faces, is also in early release and available through the nightly build. The Struts Faces taglib is expected to work with any compliant JSF implementation, including MyFaces. JSTL, the JavaServer Standard Tag Library, is a set of JSP tags that are designed to make it easier to develop Web applications. JavaServer Faces (JSF) is a specification for a new technology that promises to make it easier to write MVC applications, both for the Web and for the desktop. The inventor of Struts, Craig McClanahan, is the specification co-lead for JavaServer Faces (JSR 127), and architect of the reference implemenation as well as Java Studio Creator. Both JSTL and JSF are complementary to Struts. The mainstay of the Struts framework is the controller components, which can be used with any Java presentation technology. As new technologies become available, it is certain that new "glue" components will also appear to help these technologies work as well with Struts. Struts originally came bundled with a set of custom JSP tags. Today, several extensions are available to help you use Struts with other popular presentation technologies, like XSLT and Velocity. Likewise, extensions for JSTL and JSF are now available as well. The JSTL reference implementation is available through the Jakarta Taglibs site. A JSTL taglibs for Struts, Struts-El , is available and distributed with Struts beginning with the 1.1 release. The JSF specification and reference implementation is available through Sun's The JSF specification and reference implementation is available through Sun's Java ServerFaces page. An early-release JavaServer Faces taglib for Struts, Struts-Faces, is also in early release and available through the nightly build. The Struts Faces taglib is expected to work with any compliant JSF implementation, including MyFaces. |
|
| 48. |
Will The Struts Tags Support Other Markup Languages Such As Wml ? |
|
Answer» Struts itself is markup neutral. The original Struts taglibs are only one example of how presentation LAYER components can access the framework. The framework objects are exposed through the STANDARD application, session, and request contexts, where any Java component in the application can make use of them. Markup extensions that use Struts are available for VELOCITY and XLST, among others. A new Struts tag library for Java Server Faces is also in development. For more about USING WAP/WML with Struts see the ARTICLE WAP up your EAserver. Struts itself is markup neutral. The original Struts taglibs are only one example of how presentation layer components can access the framework. The framework objects are exposed through the standard application, session, and request contexts, where any Java component in the application can make use of them. Markup extensions that use Struts are available for Velocity and XLST, among others. A new Struts tag library for Java Server Faces is also in development. For more about using WAP/WML with Struts see the article WAP up your EAserver. |
|
| 49. |
Are The Struts Tags Xhtml Compliant ? |
|
Answer» If you USE an <html:html XHTML="true> or <html:xhtml/> element on your page, the tags will RENDER as XHTML (since Struts 1.1). If you use an <html:html xhtml="true> or <html:xhtml/> element on your page, the tags will render as XHTML (since Struts 1.1). |
|
| 50. |
Why Aren't The Struts Tags Maintained As Part Of The Jakarta Taglibs Project ? |
|
Answer» Development of both products began about the same TIME. Leading up to the release of 1.0, it was thought better to continue to develop the taglibs alongside the controller. Now that 1.0 is out, the JavaServer Pages Standard Taglib is in ACTIVE development. Once WORK on JSTL stabilizes, the Struts taglibs will be REVISITED. Tags which are not linked DIRECTLY to the framework may be hosted at Jakarta Taglibs instead. Development of both products began about the same time. Leading up to the release of 1.0, it was thought better to continue to develop the taglibs alongside the controller. Now that 1.0 is out, the JavaServer Pages Standard Taglib is in active development. Once work on JSTL stabilizes, the Struts taglibs will be revisited. Tags which are not linked directly to the framework may be hosted at Jakarta Taglibs instead. |
|