Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use components in SimpleFramework

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use components in SimpleFramework". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use components in SimpleFramework.

Describe the location of the file

The location of the XML description file is determined by the request parameter _ _ xmlpath, such as:

Http://simpleframework.net/t.do?__xmlpath=/demo/t.xml&p1=data1&p2=data2

If you are accessing a JSP file, _ _ xmlpath can be undefined, and the location of the XML description file is defaulted to the XML file with the same path and file name as the JSP file.

Under IDE such as Eclipse, you can speed up development and validity verification by introducing local XMLSchema:

...

Definition of component

All the components of SimpleFramework are defined under the components tag in the XML description file, which is different from the tag library (TagLibs) and can better separate the HTML/JSP from the definition (XML). For example, define a tree component:

...

Binding of components to page document elements

The binding between the component and the page document element is achieved through CSS Selector, and with this binding relationship, generally speaking, the component enhances the page DOM element with the following possibilities:

Add attributes and events to bound elements

Add child elements to the bound element

Move the bound element to the appropriate location

Add script support

This enhanced operation is done automatically by SimpleFramework, and the client only needs to define different binding relationships according to the differences of components, such as the tree component above, and the containerId attribute defines an ID-based selector, so that the code generated by the component needs child elements (trees) to add bound elements.

Invoking components through Javascript

The call to the component is done through a built-in Javascript object $Actions.

What is $Actions?

$Actions is a Javascript object

Actions is a Javascript object, a child of window, and can be accessed through window.$Actions or directly $Actions.

The goal and component object of $Actions

The goal of $Actions is that the client (browser) can call the component object through Javascript. Most components generate a component object that manipulates their behavior in $Actions, which can be accessed through $Actions ["name"]. Name is the name of the component, which must be defined in the component description file.

Component objects define their own properties and methods, which can be called through Javascript. For example, refresh the tree component:

$Actions ["treeName"] .refresh ()

$Actions ["name"] () is the default function of the component, and in most cases, the default function reflects the main features of the component. For example, $Actions ["ajaxRequest"] () issues an AJAX request, and $Actions ["treeName"] () constructs the entire tree.

$Actions.callSafely function

Actions defines the callSafely function to securely access the component object. Because the script starts to call the component object before it is generated when the page is loaded, the callSafely function ensures that the component object already exists before starting the call.

Thank you for your reading, the above is the content of "how to use components in SimpleFramework", after the study of this article, I believe you have a deeper understanding of how to use components in SimpleFramework, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report