Tutorials to .com

Tutorials to .com » Jsp » Tapestry-hivemind » Tapestry framework to expand research

Tapestry framework to expand research

Print View , by: iSee ,Total views: 4 ,Word Count: 1101 ,Date: Thu, 16 Apr 2009 Time: 2:33 AM

TapestryHivemindIOC,。 Introduction: tapestry framework hivemind underlying the use of the IOC in this small container, a lot of features have corresponding configuration file.
(), implementation (), configuration-point ()contribution ()。 These profiles include: service-point (service point), implementation (services), configuration-point (configuration) and contribution (to configure the realization of) the three key concepts.
,IDID。 Among them, the definition of service points of service to achieve the interface with the default, implementation can override the default realization of service points, service points, point ID and configuration in a module ID must be unique.

Tapestry4.0 not need to change the expansion of tapestry-4.0.jar file.

,tapestry- 4.0.jar/META-INF/tapestry.form.validator.xml,Validators, tapestry,,/WEB-INF/hivemodule.xml: Example 1: An example to illustrate the combination may be more easy to understand, such as tapestry-4.0.jar/META-INF/tapestry.form.validator.xml, which defines a configuration point Validators, tapestry validators are used in which If you want to increase the validator, you can / WEB-INF/hivemodule.xml added:
<contribution configuration-id="tapestry.form.validator.Validators">
" class="com.mycom.tapestry.validator.Required2"/> <validator name=" required2 "class="com.mycom.tapestry.validator.Required2"/>
</ contribution>

They can apply in the page in the validator to increase
<component id="password" type="TextField">
<binding name="value" value="password"/>
<binding name="hidden" value="true"/>
<binding name="displayName" value="message:password"/>
=login_3"/> <binding name="validators" value="validators: required2 =login_3"/>
</ component>

Note: The above two parts of code in bold must be the same.

,tapestry。 Example 2: Examples of extended services, to increase the initialization tasks tapestry.
<service-point id = "MyApplicationInitializer"
interface = "org.apache.tapestry.services.ApplicationInitializer"
visibility = "private">
<create-instance class="com.fitechlabs.xtrade.web.MyApplicationInitializer"/>
</ service-point>

<! - Hook it into the overall application initialization. ->
<contribution configuration-id="tapestry.init.ApplicationInitializers">
<command id="my-init" object="service:MyApplicationInitializer"/>
</ contribution>
tapestry will automatically start MyApplicationInitializer of the initialization task.

Class initialization need only be ApplicationInitializer interface.
public final class MyApplicationInitializer implements
ApplicationInitializer (

public void initialize (HttpServlet servlet) (
ServletContext context = servlet.getServletContext ();
String contextpath = null;
try (
contextpath = context.getResource ("/"). getPath ();

) Catch (MalformedURLException e) (
e.printStackTrace ();
if (contextpath == null)
throw new ApplicationRuntimeException (
"Error occured when getting context path.");

contextpath = contextpath.substring (contextpath.indexOf ("/") + 1);
contextpath = contextpath.substring (contextpath.indexOf ("/"));
GlobalAssets.init (contextpath);


tapestry-4.0.jar/META-INF/,tapestry。 Other: The tapestry-4.0.jar/META-INF / under the other configuration files, the tapestry can be extended many functions.

tapestry,Framework.library,,,specification-pathclasspath;mylib.library,,: The expansion of standard components: tapestry framework components provided as standard components, it is in the definition of Framework.library in if you want to modify standard components, you can modify this file, set for a suitable specification-path to the classpath; better way is to create a new library definition mylib.library, which will be the name of standard components with a new name, such as:
<component-type type="Form2" specification-path="/com/mycom/web/tapestry/form/Form.jwc"/>
Reference to the use of Form2, it can guarantee the integrity of the framework, but need to increase the database ID, such as: form @ mylib: Form.

Note: You can also Add the following line of code in their application documents, which the best!
<component-type type="Form" specification-path="/com/mycom/web/tapestry/form/Form.jwc"/>

,tapestry。 Conclusion: This essay hopes to play the role of forward and guide us to the tapestry of the many functions and expansion of arbitrary custom. So far, the expansion of the corresponding Tapestry4.0 do not need to modify and amend the tapestry-4.0.jar file, please discuss the message.

tapestry & hivemind Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.