text
stringlengths
101
200k
repo_name
stringlengths
5
73
stars
stringlengths
3
6
repo_language
stringlengths
1
24
file_name
stringlengths
2
57
mime_type
stringclasses
22 values
hash
int64
-9,223,369,786,400,666,000
9,223,339,290B
/* * Copyright 2012 astamuse company,Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.astamuse.asta4d.misc.spring.mvc.controller; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.astamuse.asta4d.web.WebApplicationConfiguration; import com.astamuse.asta4d.web.dispatch.RequestDispatcher; import com.astamuse.asta4d.web.dispatch.mapping.UrlMappingRule; import com.astamuse.asta4d.web.dispatch.mapping.UrlMappingRuleInitializer; import com.astamuse.asta4d.web.dispatch.mapping.UrlMappingRuleSet; @Controller public class GenericController implements ApplicationContextAware { private final static Logger logger = LoggerFactory.getLogger(GenericController.class); private ApplicationContext beanCtx = null; private RequestDispatcher dispatcher = new RequestDispatcher(); private List<UrlMappingRule> ruleList; public void init() { try { WebApplicationConfiguration conf = beanCtx.getBean(WebApplicationConfiguration.class); WebApplicationConfiguration.setConfiguration(conf); UrlMappingRuleSet ruleSet = conf.getUrlMappingRuleSetCls().newInstance(); UrlMappingRuleInitializer ruleInitializer = conf.getUrlMappingRuleInitializer(); ruleInitializer.initUrlMappingRules(ruleSet); ruleList = ruleSet.getArrangedRuleList(); logger.info("url mapping rules are initialized."); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } @RequestMapping(value = "/**") public void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { dispatcher.dispatchAndProcess(ruleList); /* Object contentProvider = dispatcher.handleRequest(request); return contentProvider == null ? null : convertSpringView(contentProvider); */ } @Override public void setApplicationContext(ApplicationContext context) throws BeansException { this.beanCtx = context; // we have to inovke init here because the // SpringManagedRequestHandlerResolver need to call application context. // And there is no matter that rule list is initialized in multi times, // so we do not apply a lock here. init(); } /* private View convertSpringView(ContentProvider contentProvider) throws TemplateException { if (contentProvider instanceof Asta4DPageProvider) { return new SpringWebPageView((Asta4DPageProvider) contentProvider); } else if (contentProvider instanceof RedirectActionProvider) { RedirectActionProvider redirector = (RedirectActionProvider) contentProvider; String url = RedirectUtil.setFlashScopeData(redirector.getUrl(), redirector.getFlashScopeData()); return new org.springframework.web.servlet.view.RedirectView(url); } throw new UnsupportedOperationException("ContentProvider Type:" + contentProvider.getClass().getName()); } */ }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
1,381,295,048,600,784,600
eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.8
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-2,746,484,126,835,088,400
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="asta4d-spring"> <wb-resource deploy-path="/" source-path="/src/main/java"/> </wb-module> </project-modules>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-3,464,090,364,124,113,400
<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <installed facet="jst.utility" version="1.0"/> <installed facet="java" version="1.8"/> </faceted-project>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
2,572,862,762,807,339,000
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.astamuse</groupId> <artifactId>asta4d</artifactId> <version>1.2.1-SNAPSHOT</version> </parent> <groupId>com.astamuse</groupId> <artifactId>asta4d-doc</artifactId> <version>1.2.1-SNAPSHOT</version> <packaging>jar</packaging> <name>com.astamuse.asta4d-doc</name> <description>document of asta4d</description> <repositories> <repository> <id>mvn-public</id> <name>MVNRepository</name> <url>http://mvnrepository.com</url> </repository> </repositories> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> <docVersion>${project.version}</docVersion> <docTime>${maven.build.timestamp}</docTime> </properties> <build> <plugins> <plugin> <groupId>com.agilejava.docbkx</groupId> <artifactId>docbkx-maven-plugin</artifactId> <version>2.0.16</version> <executions> <execution> <id>html-singlepage</id> <goals> <goal>generate-html</goal> </goals> <phase>generate-sources</phase> <configuration> <targetDirectory>${basedir}/target/docbkx/html-singlepage</targetDirectory> <htmlCustomization>${basedir}/src/resources/docbkx/xsl/html-singlepage.xsl</htmlCustomization> <postProcess> <copy todir="${basedir}/target/docbkx/html-singlepage"> <fileset dir="${basedir}/src/resources/docbkx"> <include name="**/*.css" /> <include name="**/*.png" /> <include name="**/*.gif" /> <include name="**/*.jpg" /> </fileset> </copy> </postProcess> </configuration> </execution> <execution> <id>html</id> <goals> <goal>generate-html</goal> </goals> <phase>generate-sources</phase> <configuration> <chunkedOutput>true</chunkedOutput> <targetDirectory>${basedir}/target/docbkx/html</targetDirectory> <htmlCustomization>${basedir}/src/resources/docbkx/xsl/html-multipage.xsl</htmlCustomization> <postProcess> <copy todir="${basedir}/target/docbkx/html"> <fileset dir="${basedir}/src/resources/docbkx"> <include name="**/*.css" /> <include name="**/*.png" /> <include name="**/*.gif" /> <include name="**/*.jpg" /> </fileset> </copy> </postProcess> </configuration> </execution> <!-- pdf cannot work correctly yet --> <execution> <id>pdf</id> <goals> <goal>generate-pdf</goal> </goals> <phase>generate-sources</phase> <configuration> <!--we cannot use abstract path by the reference of $basedir due to a bug of apache fop which cause error on windows style path, thus we use a predefined relative path by the parent. --> <admonGraphicsPath>${prjDocRoot}/src/resources/docbkx/images/</admonGraphicsPath> <imgSrcPath>${prjDocRoot}/src/resources/docbkx/</imgSrcPath> <xincludeSupported>true</xincludeSupported> <foCustomization>./src/resources/docbkx/xsl/pdf.xsl</foCustomization> </configuration> </execution> </executions> <dependencies> <!--dependency> <groupId>org.docbook</groupId> <artifactId>docbook-xml</artifactId> <version>4.4</version> <scope>runtime</scope> </dependency--> <dependency> <groupId>net.sf.xslthl</groupId> <artifactId>xslthl</artifactId> <version>2.1.0</version> <scope>runtime</scope> </dependency> <dependency> <groupId>net.sf.offo</groupId> <artifactId>fop-hyph</artifactId> <version>2.0</version> <scope>runtime</scope> </dependency> </dependencies> <!-- Common Docbook configuration --> <configuration> <sourceDirectory>${basedir}/src/docbkx</sourceDirectory> <xincludeSupported>true</xincludeSupported> <chunkedOutput>false</chunkedOutput> <useExtensions>1</useExtensions> <highlightSource>1</highlightSource> <tocMaxDepth>4</tocMaxDepth> <tocSectionDepth>3</tocSectionDepth> <entities> <entity> <name>version</name> <value>${project.version}</value> </entity> </entities> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.5</version> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build> </project>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
9,057,050,330,137,029,000
<?xml version="1.0" encoding="UTF-8"?> <book xml:id="asta4d-user-guide-book" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <bookinfo> <title> <mediaobject> <imageobject> <imagedata fileref="images/logo.png" format="PNG" scale="70"/> </imageobject> </mediaobject> Asta4D Framework User Guide </title> <keywordset> <keyword>java</keyword> <keyword>view first</keyword> <keyword>web framework</keyword> </keywordset> <productname>Asta4D Framework</productname> <releaseinfo><?eval Version: ${docVersion}?></releaseinfo> <pubdate><?eval Last update at: ${docTime}?></pubdate> <authorgroup> <author> <firstname>Rui</firstname> <surname>Liu</surname> </author> <author> <firstname>Shunsuke</firstname> <surname>Otani</surname> </author> </authorgroup> </bookinfo> <!-- front matter --> <toc></toc> <part id="asta4d-introduction"> <title>Introduction</title> <partintro id="asta4d-intro"> <para> Asta4D is a web application framework which is friendly to designer and flexible to developer. Asta4D affords high productivity than traditional MVC architecture by View First architecture. It also allows front-end engineers and back-end engineers work independently without interference by separating rendering logic from template files. </para> <para> Asta4D is inspired by lift which is a famous scala web application framework and it is developed by astamuse company Ltd. locating at Tokyo Japan. We are concentrating on global innovation support and developing Asta4D for our own services. Currently, Asta4D is driving our new service development. </para> </partintro> <xi:include href="en/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </part> <part id="asta4d-user-guide"> <title>User Guide</title> <xi:include href="en/inheritable_template.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/renderer.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/url_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/side_effect.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/request_handler.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/adv_request_handler.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/form_flow.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/best_practice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </part> <part id="asta4d-reference"> <title>Reference</title> <xi:include href="en/detail_template.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_snippet.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_var_injection.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_url_rule.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_form_flow.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_i18n.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_servlet_conf.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="en/detail_integration_spring.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </part> </book>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,863,429,891,497,139,000
<?xml version="1.0" encoding="UTF-8"?> <book xml:id="asta4d-user-guide-jp" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <bookinfo> <title>Asta4D Framework ユーザガイド</title> <productname>Asta4D Framework</productname> <releaseinfo>0.1</releaseinfo> <authorgroup> <author> <firstname>Shunsuke</firstname> <surname>Otani</surname> </author> <author> <firstname>Rui</firstname> <surname>Liu</surname> </author> </authorgroup> </bookinfo> <!-- front matter --> <toc></toc> <part id="asta4d-introduction"> <title>Asta4Dの概要</title> <partintro id="asta4d-core-intro"> <para>Asta4Dはデザインフレンドリーと開発に柔軟性を持たせるという特徴を持つWEB アプリケーションフレームワークです。</para> <xi:include href="jp/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </partintro> </part> <part id="asta4d-functionality"> <title>Asta4Dの機能</title> <partintro id="asta4d-function"> <para>これから、機能を説明します。最低限実装が必要な箇所は GenericController・Template・Snippetの三つのみです。</para> <xi:include href="jp/controller.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/template.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/snippet.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/renderer.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/request_handler.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/interceptor.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="jp/contextdata.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </partintro> </part> </book>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,819,607,568,084,375,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-form-flow" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Built in form flow</title> <remark>(Being written. See the online sample: <ulink url="http://asta4dsample-xzer.rhcloud.com/form">Form Flow Sample</ulink>)</remark> <para>Asta4D affords built-in form flow to accelerate development of traditional form process. Asta4D's form flow mechanism supports various flow style and supplies several classical flow style as built-in. For most cases, the developers only need to implement the init and update method to complete the entire form related logic.</para> <sect1> <title>Startup</title> <sect2> <title>Form and form field</title> <para>In a form process, the basic conception is a POJO which represents the whole form data. In Asta4D, we use @Form annotation to annotate a POJO as a form object which can be handled by the the form flow.</para> <para>Also, there must be fields to represent the concrete data of a form, which can also be annotated by a set of form field annotations. There are several built-in form field annotations for common cases and you can implement your own form field annotation too(See <xref linkend="chapter-detail-form-flow"/> for more details about form field annotation).</para> <example> <title>annotations on form POJO and form fields</title> <programlisting language="java"> <![CDATA[ @Form public class PersonForm extends Person{ @Hidden public Integer getId() { return super.getId(); } @Input public String getName() { return super.getName(); } @Select(name = "bloodtype") public BloodType getBloodType() { return super.getBloodType(); } } ]]> </programlisting> <remark>The @Hidden represents a hidden input of html, @Input represents a traditional common input and @Select is matched to the pull-down element in html. We also recommend to implement the form POJO by extending from the existing entity POJO, see details at <xref linkend="common-usage-form-flow"/>. </remark> </example> </sect2> <sect2> <title>Form handler</title> <sect3> <title>Brief of BasicFormFlowHandlerTrait and FormProcessData</title> <para>After we defined our form POJO, we need to declare a request handler to handle the form request. There is an BasicFormFlowHandlerTrait which affords most necessary common operations of form process.</para> <para>The BasicFormFlowHandlerTrait is implemented as an interface with various default methods which afford a template that allows developer to override any method for customization.</para> <para>To define a form flow, we need to plan a flow graph which describes how the flow flows.</para> <para>(before first) &lt;--&gt; step 1 &lt;--&gt; step2 &lt;--&gt; step3 &lt;--&gt; ...</para> <para>Assume we have a flow as above, note that there can be cycles or branches, which means you can go any step from any other step in the flow graph, what you need to do is to define how the step should be transfered. For example, the following flow graph is possible:</para> <para>(before first) --&gt; step 1 &lt;--&gt; step2 &lt;--&gt; step3 --&gt; (finish)</para> <para>(before first) --&gt; step 1 &lt;--&gt; step4 &lt;--&gt; step5 --&gt; (finish)</para> <para>step 1 &lt;-- step3</para> <para>step 1 &lt;-- step5</para> <para>To describe the step transfer, there is an interface called FormProcessData which defined the basic step information:</para> <example> <title>FormProcessData</title> <programlisting language="java"> <![CDATA[ public interface FormProcessData { public abstract String getStepExit(); public abstract String getStepBack(); public abstract String getStepCurrent(); public abstract String getStepFailed(); public abstract String getStepSuccess(); public abstract String getFlowTraceId(); } ]]> </programlisting> </example> <para>The FormProcessData requires the developer to tell how to handle a form submit, the name of current step, the target step for success and the target for failing, also want to know where to go if user want to go back to the previous step or exit. The getFlowTraceId will return a id which represents all the state of current flow(can be considered as a "session" id for the current in-progress form flow).</para> <para>The default implementation of FormProcessData is SimpleFormProcessData which retrieves the step information from the submitted http query parameters which can be put into the HTML template files as a part of the submitting form. However developers can always decide how to retrieve the step information by implement their own FormProcessData.</para> <example> <title>SimpleFormProcessData</title> <programlisting language="java"> <![CDATA[ @ContextDataSet public class SimpleFormProcessData implements FormProcessData { @QueryParam(name = "step-exit") private String stepExit; @QueryParam(name = "step-back") private String stepBack; @QueryParam(name = "step-current") private String stepCurrent; @QueryParam(name = "step-failed") private String stepFailed; @QueryParam(name = "step-success") private String stepSuccess; @QueryParam(name = FormFlowConstants.FORM_FLOW_TRACE_ID_QUERY_PARAM) private String flowTraceId; } ]]> </programlisting> </example> <para>If we use the default SimpleFormProcessData, we will usually include the following HTML in our template file side:</para> <example> <title>HTML for SimpleFormProcessData</title> <programlisting language="xml"> <![CDATA[ <input type="hidden" name="step-current" value="confirm"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">send</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input">back</button> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> ]]> </programlisting> </example> <para>The details of how the BasicFormFlowHandlerTrait process the submitted form data and transfer the step can be found at the JavaDoc of BasicFormFlowHandlerTrait. Here we will introduce the points that what the developers have to do to decide the rule of a form flow. There are 3 methods should be overridden for a certain flow rule:</para> <itemizedlist> <listitem> <para>String createTemplateFilePathForStep(String step)</para> <para>decide how to convert a step to the corresponding target template file path</para> </listitem> <listitem> <para>boolean skipStoreTraceData(String currentStep, String renderTargetStep, FormFlowTraceData traceData)</para> <para>decide whether the flow trace data should be stored</para> </listitem> <listitem> <para>boolean passDataToSnippetByFlash(String currentStep, String renderTargetStep, FormFlowTraceData traceData)</para> <para>decide how to pass the form data for rendering to snippet, by flash scope or not.</para> </listitem> </itemizedlist> <para>For most common situations, all the above things can be decided as general rules in the user project, so that a common parent class can be utilized to perform the common assumption. There are two built-in flows representing the classical situations: OneStepFormHandlerTrait and ClassicalMultiStepFormFlowHandlerTrait. Those two built-in interfaces will be introduced in the next section and can be considered as reference implementation of how to design and decide a form flow. User project is always recommended to extend from those two built-in flows rather than the basic mechanism trait BasicFormFlowHandlerTrait. </para> </sect3> <sect3> <title>built-in flows</title> <para>There are two built-in handler traits to handle the most common situations of the form flow, which are OneStepFormHandlerTrait and ClassicalMultiStepFormFlowHandlerTrait.</para> <para>The OneStepFormHandlerTrait represents a most simple form process: there is a single input page, after submit, the submitted data will be handled and then return to a before-input page which is usually a list page of items. To use OneStepFormHandlerTrait, you need to put the following HTML in your form template files if you are using the default SimpleFormProcessData:</para> <example> <title>SimpleFormProcessData HTML for OneStepFormHandlerTrait</title> <programlisting language="xml"> <![CDATA[ <input type="hidden" name="step-current" value="input"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">save</button> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> ]]> </programlisting> <remark>By OneStepFormHandlerTrait's default implementation, the "step-current" and "step-failed" must be "input", the "step-success" and the "step-exit" can be any non empty value (usually "complete" and "exit" is good enough).</remark> </example> <para>The ClassicalMultiStepFormFlowHandlerTrait represents a little bit complicated situations: there are multiple steps in the flow. ClassicalMultiStepFormFlowHandlerTrait assumes that there is at least one input page and one confirm page with a possible complete page. For the single input page case, ClassicalMultiStepFormFlowHandlerTrait can be used directly, but if there are multiple splitted input pages, the developer need to do more customization.</para> <para>For a classical 3-step form flow(input, confirm, complete), the following HTML need to be put into the form template files:</para> <example> <title>SimpleFormProcessData HTML for ClassicalMultiStepFormFlowHandlerTrait - buttons of input page</title> <programlisting language="xml"> <![CDATA[ <input type="hidden" name="step-current" value="input"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="confirm">confirm</button> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> ]]> </programlisting> <remark>At input page, the "step-current" and "step-failed" must be "input", the "step-success" must be "confirm", the "step-exit" can be any non empty value (usually "exit" is good enough).</remark> </example> <example> <title>SimpleFormProcessData HTML for ClassicalMultiStepFormFlowHandlerTrait - buttons of confirm page</title> <programlisting language="xml"> <![CDATA[ <input type="hidden" name="step-current" value="confirm"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">send</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input">back</button> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> ]]> </programlisting> <remark>At confirm page, the "step-current" must be "confirm","the step-failed" must be "input", the "step-success" must be "complete", the "step-back" must be "input", the "step-exit" can be any non empty value (usually "exit" is good enough).</remark> </example> <example> <title>SimpleFormProcessData HTML for ClassicalMultiStepFormFlowHandlerTrait - buttons of complete page</title> <programlisting language="xml"> <![CDATA[ <button type="submit" name="step-exit" value="exit">return</button> ]]> </programlisting> <remark>At complete page, a non empty value of "step-exit" is enough.</remark> </example> <remark>Note that the value of steps' name are not fixed and you can always define your own names by overriding the corresponding methods about step names at ClassicalMultiStepFormFlowHandlerTrait.</remark> </sect3> <sect3> <title>Implement a real form flow handler</title> <para>As introduced in previous sections, we should always extend our own handler from the built-in classical traits, before which we also have to decide what our flow should be: one step or multiple steps?</para> <para>Further, In user project, a common parent class is always recommended. A project limited common parent class can be used to decide the special rules of the user project and the following two method is strongly recommended to be overridden to return a configured and validator.</para> <itemizedlist> <listitem> <para>getTypeUnMatchValidator()</para> </listitem> <listitem> <para>getValueValidator()</para> </listitem> </itemizedlist> <example> <title>A common parent handler in project:</title> <programlisting language="java"> <![CDATA[ /** * A common parent handler to configure the common actions of form flow process in application. <br> * For quick start, an empty class body would be good enough. You only need to do the customization when you really need to do it!!! * */ public abstract class Asta4DSamplePrjCommonFormHandler<T> implements ClassicalMultiStepFormFlowHandlerTrait<T> { // we use a field to store a pre generated instance rather than create it at every time private SamplePrjTypeUnMatchValidator typeValidator = new SamplePrjTypeUnMatchValidator(false); // as the same as type validator, we cache the value validator instance here private SamplePrjValueValidator valueValidator = new SamplePrjValueValidator(false); @Override public FormValidator getTypeUnMatchValidator() { return typeValidator; } @Override public FormValidator getValueValidator() { return valueValidator; } } ]]> </programlisting> <remark>At confirm page, the "step-current" must be "confirm","the step-failed" must be "input", the "step-success" must be "complete", the "step-back" must be "input", the "step-exit" can be any non empty value (usually "exit" is good enough).</remark> </example> <para>More details about validator can be found at later section.</para> <para>In both OneStepFormHandlerTrait and ClassicalMultiStepFormFlowHandlerTrait, there are 3 methods which are required to be implemented by developers.</para> <itemizedlist> <listitem> <para>Class&lt;T&gt; getFormCls()</para> <para>Which specify the form type of current </para> </listitem> <listitem> <para>T createInitForm()</para> <para>To create form instance from the current request context. By default, this method will build a form instance from context by the given type returned by getFormCls(). A handler which need to retrieve the initial form data from storage should override this method to afford a initial form instance. For common cases, a handler for adding is not necessary to override this method but a handler for updating should override this method to query database and build the corresponding form instance.</para> <example> <title>query updating target data from db in createInitForm()</title> <programlisting language="java"> <![CDATA[ @Override protected PersonFormForMultiStep createInitForm() throws Exception { PersonFormForMultiStep form = super.createInitForm(); if (form.getId() == null) {// add return form; } else {// update // retrieve the form form db again return PersonFormForMultiStep.buildFromPerson(PersonDbManager.instance().find(form.getId())); } } ]]> </programlisting> </example> </listitem> <listitem> <para>void updateForm(T form)</para> <para>Which is supposed to perform the final update logic of current form flow.</para> <example> <title>update form data</title> <programlisting language="java"> <![CDATA[ @Override protected void updateForm(PersonFormForMultiStep form) { DefaultMessageRenderingHelper msgHelper = DefaultMessageRenderingHelper.getConfiguredInstance(); if (form.getId() == null) {// add PersonDbManager.instance().add(Person.createByForm(form)); // output the success message to the global message bar msgHelper.info("data inserted"); } else {// update Person p = Person.createByForm(form); PersonDbManager.instance().update(p); // output the success message to specified DOM rather than the global message bar msgHelper.info(".x-success-msg", "update succeed"); } } ]]> </programlisting> <remark>Note that there is a built-in message rendering mechanism to help developer supply a responsive interaction more easily. The details will be introduced later, simply remember that you can output message by info/warn/error levels.</remark> </example> </listitem> </itemizedlist> </sect3> </sect2> <sect2> <title>HTML template of form</title> <para>As the common pages of Asta4D, the HTML template of a form is as pure HTML too.</para> <example> <title>Form template</title> <programlisting language="xml"> <![CDATA[ <form method="post" afd:render="form.SingleInputFormSnippet"> <input name="name" type="text"/> <input name="age" type="text"/> <input id="sex" name="sex" type="radio"/><label for="sex">M</label> <select id="bloodtype" name="bloodtype"> <option value="A">A</option> <option value="R" afd:clear>R</option> </select> <input id="language" name="language" type="checkbox"/><label for="language">M</label> <textarea name="memo"></textarea> <input type="hidden" name="id"> <afd:embed target="/templates/form/singleInput/btns.html" /> </form> ]]> </programlisting> </example> <para>As you see in the above example, there is no special declaration in the template, let us see how to declare a form POJO to handle the various form field types:</para> <example> <title>form template</title> <programlisting language="java"> <![CDATA[ //@Form to tell the framework this class can be initialized from context //extend from the entity POJO to annotate form field definitions on getters. @Form public class PersonForm { @Hidden private Integer id; @Input private String name; @Input private Integer age; @Select(name = "bloodtype") private BloodType bloodType; // the field name would be displayed as "gender" rather than the original field name "sex" in validation messages @Radio(nameLabel = "gender") private SEX sex; @Checkbox private Language[] language; @Textarea private String memo; } ]]> </programlisting> </example> <para>The details of annotations will be introduced later, just remember that there is always an annotation which can represent a certain type of form field.</para> <para>Another point here is that you can always declare all the fields by your business type rather than string type, the framework will handle the value conversion correctly.</para> </sect2> <sect2> <title>Form snippet</title> <para>To render the form values to template, we have to declare a snippet which extends from the AbstractFormFlowSnippet. As the same as the built-in two classical handler traits, there are two corresponding snippet traits: OneStepFormSnippetTrait and ClassicalMultiStepFormFlowSnippetTrait. </para> <para>Also as the same as handlers, a project common parent snippet is recommended to perform common customization.</para> <example> <title>Form snippet implementation</title> <programlisting language="java"> <![CDATA[ public class SingleInputFormSnippet extends Asta4DSamplePrjCommonFormSnippet { /** * override this method to supply the option data for select, radio and checkbox. */ @Override protected List<FormFieldPrepareRenderer> retrieveFieldPrepareRenderers(String renderTargetStep, Object form) { List<FormFieldPrepareRenderer> list = new LinkedList<>(); list.add(new SelectPrepareRenderer(PersonForm.class, "bloodtype").setOptionData(BloodType.asOptionValueMap)); list.add(new RadioPrepareRenderer(PersonForm.class, "sex").setOptionData(SEX.asOptionValueMap)); list.add(new CheckboxPrepareRenderer(PersonForm.class, "language").setOptionData(Language.asOptionValueMap)); return list; } } ]]> </programlisting> </example> <para>Developers are usually asked to override the retrieveFieldPrepareRenderers method to supply extra data for field rendering, commonly the list of option data is required.</para> <para>SelectPrepareRenderer can be used to afford option list for select element, RadioPrepareRenderer and CheckboxPrepareRenderer can be used for radio and checbox input element.</para> <para>Finally, do not forget to put your snippet declaration in your template file.</para> <example> <title>Declare snippet in form template</title> <programlisting language="xml"> <![CDATA[ <form method="post" afd:render="form.SingleInputFormSnippet"> </form> ]]> </programlisting> </example> <para>Basically, until now we have gotten a workable form flow implementation. There is only one thing left that is validation which will be described in the next section.</para> </sect2> <sect2> <title>Cascade form POJO and array field</title> </sect2> </sect1> <sect1> <title>Advanced</title> <sect2> <title>Validation</title> <para>Asta4D allows any validation mechanism to be integrated and supports Bean Validation 1.1(JSR349 and JSR303) by default. We will explain how to use the built-in Bean Validation mechanism in this section. The later section will introduce how to customize the validation.</para> <para>To use Bean Validation, just simply add validation annotations to your form POJO as following:</para> <example> <title>Declare validation annotations</title> <programlisting language="java"> <![CDATA[ @NotBlank @Size(max = 6) public String getName() { return name; } public void setName(String name) { this.name = name; } @Max(45) @NotNull public Integer getAge() { return age; } ]]> </programlisting> </example> <para>More details of Bean Validation can be found at <ulink url="http://beanvalidation.org/">Bean Validation</ulink>. We are also using Hibernate Validator as the implementation(the only existing one in the earth currently). See details at <ulink url="http://hibernate.org/validator/">Hibernate Validator</ulink>.</para> <para>The validation will be invoked before the calling of method updateForm, if there is any validation error, the page will be forwarded to the step specified by "step-failed" which is usually the input page, and the validation error message will be rendered to page too. More details about validation message rendering will be introduced in later sections.</para> <para>As recommended before, a project common parent class is recommended to afford a configured validator or any other customized validator implementation.</para> </sect2> <sect2> <title>Message rendering</title> </sect2> <sect2> <title>Customize form field annotation</title> </sect2> <sect2> <title>A sample of defining a new flow rule</title> <para>(Include about how to implement multiple input steps)</para> </sect2> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,552,775,699,632,004,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-request-handler" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Impement request handler and url mapping</title> <section> <title>@RequestHandler</title> <para>It is not complicated to implement a request handler. @RequestHandler can be used to annotate a handle method in arbitrary Java class which will be treated as a request handler.</para> <example> <programlisting language="java"> <![CDATA[ public class LoginHandler { @RequestHandler public LoginFailure doLogin(String flag) throws LoginFailure { if (StringUtils.isEmpty(flag)) { return null; } if ("error".equals(flag)) { throw new LoginFailure(); } if (!Boolean.parseBoolean(flag)) { return new LoginFailure(); } return null; } } ]]> </programlisting> <para> Take a look at the parameters of the handle method, the handle method of a request handler accepts parameter injection as same as the snippet method. More details can be found at the descriptions of the snippet method. </para> </example> </section> <section> <title>delcare url rule for request handler</title> <para>Previously we have introduced how to forward a http request to a certain template file by url mapping. We can declare a request handler for q http request by the same way: </para> <example> <programlisting language="java"> <![CDATA[ rules.add("/app/handler") .handler(LoginHandler.class) // (1) .forward(LoginFailure.class, "/templates/error.html") //(2) .redirect(FurtherConfirm.class, "/app/furtherConfirm")//(3) .forward("/templates/success.html"); //(4) ]]> </programlisting> <para> Simply explain: <orderedlist> <listitem> <para>Forward the request to "/app/handler" to the request handler "LoginHandler".</para> </listitem> <listitem> <para>If "LoginHandler" returns a result of "LoginFailure", forward the request to the template file "error.html".</para> </listitem> <listitem> <para>If "LoginHandler" returns a result of "FurtherConfirm", redirect the current request to "/app/furtherConfirm" by http code 302(302 is by default).</para> </listitem> <listitem> <para>If "LoginHandler" does not return a meaningful result(it usually means success by a null return) , forward the request to the template file "success.html".</para> </listitem> </orderedlist> </para> </example> <para> More verbose details: </para> <para> The handler method is used to add a request handler and accepts arbitrary type as the the parameter: an instance of java.lang.Class or an arbitrary instance. The framework explains received parameters by the implementation of DeclareInstanceResolver configured by WebApplicationConfiguration. Thee default implementation provided by framework follows the following rules to explain the declaration of request handler: <orderedlist> <listitem> <para>If an instance of java.lang.Class is specified, the instance of request handler will be created by invoke "newInstance()" on the specified Class.</para> </listitem> <listitem> <para>If a string is specified, the string will be treated as a class name and an instance of java.lang.Class will be created by calling "Class#forName", then the instance of request handler will be created by invoke "newInstance()" on the created Class.</para> </listitem> <listitem> <para>The specified parameter will be treated as a request handler directly if it is neither a Class nor a string. By this rule, it is interesting that we can declare an anonymous class as a request handler:</para> <example> <programlisting language="java"> <![CDATA[ rules.add("/app/handler") .handler(new Object(){ @RequestHandler public void handle(){ // } }); ]]> </programlisting> </example> </listitem> </orderedlist> <remark>The asta4d-spring package also provides a resolver based on Spring IOC container, the request handler instance will be retrieved by passing the specified parameter to the "Context#getBean" method of spring container.</remark> </para> <para> The forward method adds a transforming rule for the result of request handler.There must be a handler method annotated by @RequestHandler and the returned value of the handle method is viewed as the result of the request handler, thrown exceptions in the handle method are treated as the result too. The framework will attempt to match the result to the expected result specified by forward method then transforms the result to the corresponding template file(The real mechanism of result transforming is more complicated and is explained at ...). When the matching attempt is performed, the equals method will be used at first, if the equals method returns false and the expected result by forward method is an instance of java.lang.Class, "Class#isAssignableFrom" will be utilized, if false again, skip the current forward rule and do the same check on the next forward rule. A forward rule without the expected result specified will be viewed as a default rule, if matched forward rule for a result is missing or the request handler returns a pointless result(void declaration of handle method or returns null), the default rule will be applied. </para> <para> The redirect method follows the same rule of forward method except it will cause a 302 redirect(302 is default, 301 can be declared) instead of forwarding to a template file. </para> </section> <section> <title>Default request handler</title> <para> You can not only declare request handler to a certain url, but also declare global request handlers which is available to all the urls and prior to the request handlers declared on certain urls. There is a conception of request handler chain for multi handlers, we will explain it in a later chapter. </para> <example> <title>Default request handler</title> <programlisting language="java"> <![CDATA[ rules.addDefaultRequestHandler(GlobalHandler.class); rules.addDefaultRequestHandler("authcheck", AuthCheckHandler.class); ]]> </programlisting> </example> <para> At the second line declaration for AuthCheckHandler, an attribute can be specified at the same time, which cause the declared request handler is only available to the rules that declared the same attribute. </para> <example> <programlisting language="java"> <![CDATA[ rules.add("/app/handler").attribute("authcheck") ... ]]> </programlisting> </example> <remark> In the framework's internal implementation, a static match rule table will be generated after all the url mapping declaration finished. A global request handler that is only available to certain rules will be configured to the the certain url rules only, by which unnecessary performance cost is avoid. </remark> <para> In our practice, we found that it is very inconvenient to declare necessary attribute on every rule. In most situations, we will want to do something like configure a same default request handler to all the url paths under "/xxx", which can be done by delcaring a non attribute default request handler which judges the url pattern by itself, but such way will lose the performance benefit of attribute declaration. Thus, we provide an alternative way for this situation: url rule rewrite. </para> <example> <programlisting language="java"> <![CDATA[ rules.addRuleRewriter(new UrlMappingRuleRewriter() { @Override public void rewrite(UrlMappingRule rule) { if(rule.getSourcePath().startsWith("/privatedata/")){ rule.getAttributeList().add("authcheck"); } } }); ]]> </programlisting> </example> <para> Please note that, untill now all the introduced configuration for url mapping are achieved by a group of interface called HandyRule which convert all the declaration to the instance of UrlMappingRule which is used by framework internally. But in the url rule rewritter implementation, developers have to cope with the raw UrlMappingRule which is difficult to understand, so complex url rewriting is not appreciated. Basically, the scenario of url rule rewriting is only for add attributes to rules in bulk. </para> </section> <section> <title>Global forward/redirect</title> <para> Previously we mentioned that the result of a request handler will be matched in the forward declaration, if there is no matched forward found, the global forward rule will be checked. </para> <example> <title>Global forward</title> <programlisting language="java"> <![CDATA[ rules.addGlobalForward(PageNotFoundException.class, "/pagenotfound.html", 404); ]]> </programlisting> <para> The above source declares that if the result of request handler is PageNotFoundException(Exception is treated as the result of the request handler), forward the request to pagenotfound.html by http status code 404. </para> </example> <para> Global redirect can be declared by the same way. </para> <example> <title>Global redirect</title> <programlisting language="java"> <![CDATA[ rules.addGlobalRedirect(REDIRECT_TO_SOMEWHERE, "/somewhere"); ]]> </programlisting> </example> <para> The global forward rules are applied before the default forward rule(the forward rule without result) on certain url mapping rule. </para> <example> <programlisting language="java"> <![CDATA[ rules.addGlobalForward(PageNotFoundException.class, "/pagenotfound.html", 404); rules.addGlobalRedirect(REDIRECT_TO_SOMEWHERE, "/somewhere"); rules.add("/app/handler") .handler(LoginHandler.class) .forward(LoginFailure.class, "/templates/error.html") .redirect(FurtherConfirm.class, "/app/furtherConfirm") .forward("/templates/success.html"); ]]> </programlisting> </example> <para> In the above sample, the result of LoginHandler will be matched by the following order: <orderedlist> <listitem>LoginFailer</listitem> <listitem>FurtherConfirm</listitem> <listitem>PageNotFoundException</listitem> <listitem>REDIRECT_TO_SOMEWHERE</listitem> <listitem>(default-> "success.html")</listitem> </orderedlist> </para> </section> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,545,282,352,170,154,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-template" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Details of Template</title> <sect1> <title>Supported tags</title> <toc></toc> <sect2> <title>afd:extension</title> <para>A "afd:extension" tag declares the relationship of inheritance between child template and parent template.</para> <example><title>child.html</title> <programlisting language="xml"> <![CDATA[ <afd:extension parent="parent.html"> ... </afd:extension> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <varlistentry> <term>parent</term> <listitem> <para>Identifies the parent template file of the current template.</para> </listitem> </varlistentry> </variablelist> </sect2> <sect2> <title>afd:block</title> <para>A "afd:block" tag declares a referenceable block in the template file. Child template file can reference the blocks in parent template by the same tag "afd:block" with extra action declaration: append, insert, override. </para> <example><title>parent.html</title> <programlisting language="xml"> <![CDATA[ <html> <head> <afd:block id="block1"> <link href="parent1.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block id="block2"> <link href="parent2.css" rel="stylesheet" type="text/css" /> </afd:block> <title>extension sample</title> </head> <body> <afd:block id="content">content</afd:block> </body> </html> ]]> </programlisting> </example> <example><title>child.html</title> <programlisting language="xml"> <![CDATA[ <afd:extension parent="parent.html"> <afd:block append="block1"> <link href="child1.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block insert="block2"> <link href="child2.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block override="content"> <div>hello</div> </afd:block> </afd:extension> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <varlistentry> <term>id</term> <listitem> <para>The referenceable id of a block.</para> </listitem> </varlistentry> <varlistentry> <term>append</term> <listitem> <para> Append all the children of current tag to the tail of the parent's block which id equals the declared value of the append attribute. </para> </listitem> </varlistentry> <varlistentry> <term>insert</term> <listitem> <para> Insert all the children of current tag to the head of the parent's block which id equals the declared value of the insert attribute. </para> </listitem> </varlistentry> <varlistentry> <term>override</term> <listitem> <para> Override the parent's block which id equals the declared value of the override attribute by all the children of current tag. </para> </listitem> </varlistentry> </variablelist> <remark>The result of merging the above two files by Asta4D's template engine can be found at <xref linkend="chapter-Inheritable-template"/>.</remark> </sect2> <sect2> <title>afd:embed</title> <para>A "afd:embed" tag declares an action of extracting and inserting an external file's content to the site where the "afd:embed" tag is declared.</para> <example><title>child.html</title> <programlisting language="xml"> <![CDATA[ <afd:extension parent="parent.html"> <afd:block override="content "> <div>hello</div> <afd:embed target="/templates/embed.html" ></afd:embed> </afd:block> </afd:extension> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <varlistentry> <term>target</term> <listitem> <para>The path of which file should be included at the declaration site.</para> </listitem> </varlistentry> </variablelist> <remark>In the embed target file, afd:block can also be used to append/insert/override the blocks in source template. Samples and the merging result can be found at <xref linkend="chapter-Inheritable-template"/>. </remark> </sect2> <sect2> <title>afd:snippet</title> <para>A "afd:snippet" tag declares an Java class which assumes the duty of rendering data to the html snippet contained by the declaring tag.</para> <example> <programlisting language="xml"> <![CDATA[ <afd:snippet render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <varlistentry> <term>render</term> <listitem> <para>The snippet class name and render method name by format:&lt;class name&gt;:&lt;method name&gt;, the class name and the method name are split by colon. If the method name is omitted, the default method name "render" will be used. </para> </listitem> </varlistentry> <varlistentry> <term>parallel</term> <listitem> <para>A snippet tag with "parallel" attribute will be executed in a separated thread from the main thread of current http request. It is not necessary to assign a value to this attribute. </para> </listitem> </varlistentry> <varlistentry> <term>clear</term> <listitem> <para>A snippet tag with "clear" attribute will not be executed and will be removed from the final output page. This is useful for disabling certain contents temporarily in certain situations such as debug. It is not necessary to assign a value to this attribute. </para> </listitem> </varlistentry> </variablelist> <para> There is an alternative way to declare a snippet by "afd:render" attribute. </para> <example> <programlisting language="xml"> <![CDATA[ <div afd:render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </div> ]]> </programlisting> </example> <para>By the same way, "afd:paralell" and "afd:clear" can be used on arbitrary html tags which will be treated as the same as a "afd:snippet" tag. Note that "afd:paralell" will not be available except the "afd:render" is declared too, but the "afd:clear" will be always available even there is no declaration of "afd:render" on the html tag. </para> </sect2> <sect2> <title>afd:group</title> <para>A "afd:group" tag declares a referenceable DOM element for back-end Java snippet class. It is useful to reference certain text without wrapping html tag or combine a group of coordinate html tags as a single node.</para> <example> <programlisting language="xml"> <![CDATA[ <p>We found <afd:group id="item-count">3</afd:group> matched items in our database.</p> <afd:group id="list-item"> <div id="title">the title</div> <div id="content">the content</div> </afd:group> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <remark>None.</remark> </variablelist> </sect2> <sect2> <title>afd:comment</title> <para>A "afd:comment" tag declares a comment block in the template files and it will be removed after rendering.</para> <example> <programlisting language="xml"> <![CDATA[ <afd:comment>This is comment</afd:comment> <afd:comment> <div>This is comment too.</div> </afd:comment> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <remark>None.</remark> </variablelist> </sect2> <sect2> <title>afd:msg</title> <para>A "afd:msg" tag declares a message managed in external files. This tag is mainly designed for i18n support, but it also can be used as a simple string replacer. Please see <xref linkend="chapter-detail-i18n"/> for more details.</para> <example> <programlisting language="xml"> <![CDATA[ <afd:msg key="search.result.count"></afd:message> ]]> </programlisting> </example> <variablelist> <title>Attributes:</title> <varlistentry> <term>key</term> <listitem> <para>The message key which should can be found in the configured message file.</para> </listitem> </varlistentry> </variablelist> </sect2> </sect1> <sect1> <title>Additional</title> <itemizedlist> <listitem> <para>HTML5 convention</para> <para> Asta4D's template engine does only support html5, which relies on the underline library <ulink url="http://jsoup.org">jsoup(verion 1.6.3)</ulink>. jsoup implements the <ulink url="http://whatwg.org/html">WHATWG HTML5</ulink> specification and requires compliance from the target file. jsoup can fix some cases of breaking specification but you would still get unexpected result for certain cases. Basically, you should take care of the following things: <itemizedlist> <listitem><para>All tags and attributes are converted to lower case.</para></listitem> <listitem><para>Self closed tags such as &lt;div /&gt; or &lt;afd:embed target="embed.html" /&gt; is not legal.</para></listitem> <listitem><para>There are some tags that the parser "ensures".For example a &lt;tbody&gt; tag must be the first tag inside &lt;table&gt;, which breas the following example:</para> <example> <programlisting language="xml"> <![CDATA[ <table> <afd:snippet render="ListSnippet"> <tr><td></td></tr> </afd:snippet> </table> ]]> </programlisting> </example> <para>But it can be replaced by the following:</para> <example> <programlisting language="xml"> <![CDATA[ <table> <tr afd:render="ListSnippet"><td></td></tr> </table> ]]> </programlisting> </example> </listitem> </itemizedlist> </para> </listitem> <listitem> <para>body convention</para> <para>When a child template file uses "afd:extension" to declare its parent template, only the body part(all the children of the body except the body tag itself) of the child template will be processed by the template engine and the parts out of body will be ignored simply. The same convention is applied to the embed target file. The following two sample will not cause different results by Asta4D.</para> <example><title>child.html without body tag:</title> <programlisting language="xml"> <![CDATA[ <afd:extension parent="parent.html"> <afd:block override="content "> <div>hello</div> <afd:embed target="/templates/embed.html" ></afd:embed> </afd:block> </afd:extension> ]]> </programlisting> </example> <example id="child-with-body-tag"><title>child.html with body tag:</title> <programlisting language="xml"> <![CDATA[ <html> <head> <meta charset="UTF-8"> </head> <body> <afd:extension parent="parent.html"> <afd:block override="content "> <div>hello</div> <afd:embed target="/templates/embed.html" ></afd:embed> </afd:block> </afd:extension> </body> </html> ]]> </programlisting> </example> <para> This convention can be used for editor compatibility in case of your prefer html editor requires correct meta information (We add charset="UTF-8" to all of our template files for this reason). Note that this convention is only available on extended child template file or embedded target file, the parts out of body tag will be processed normally in the parent template file which is as a root template without further parent. </para> <para> Further, explicit parameter information can be commented at body tag in parameterizable embed target file for better source readability. </para> <example id="embed-with-parameter-declaring"><title>embed.html</title> <programlisting language="xml"> <![CDATA[ <html> <head><meta charset="UTF-8"></head> <body itemsize="{Integer}" itemlist="{List}"> <afd:block append="block1"> <link href="embed.css" rel="stylesheet" type="text/css" /> </afd:block> <div>good embed</div> </body> </html> ]]> </programlisting> <para> In <xref linkend="embed-with-parameter-declaring" />, we put some "strange" information in the body tag, which suggests that when this file is embedded, it requires an Integer parameter named "itemsize" and a List parameter named "itemlist". Note that such declaration can only be regarded as a hint for source reader and there is no warranty about any parameter check. You should consider it as a sample of how you can make interesting use of the body convention. </para> </example> <sbr/> </listitem> <listitem> <para>"afd" name space</para> <para>The "afd" name space is configured as the default name space of Asta4D's special tags. This name space can be changed by Configuration#setTagNameSpace.</para> <sbr/> </listitem> <listitem> <para>TemplateResolver</para> <para>Asta4D searches certain template file by configured TemplateResolver. There are three pre-implemented TemplateResolver: FileTemplateResolver, ClasspathTemplateResolver and WebApplicationTemplateResolver. The default configured WebApplicationTemplateResolver will search template files with awareness of servlet container. The FileTemplateResolver and ClasspathTemplateResolver can be used for test purpose, you can also provide your own TemplateResolver for special search mechanism. </para> </listitem> </itemizedlist> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,337,311,528,522,516,500
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="url-mapping" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>View first URL mapping and variable injection</title> <section id="view-first-mechanism"> <title>View first</title> <para> In Asta4D, we follow the principle of view first rather than the tradition MVC architecture. The declaration of URL rules does not need to include a controller and one url can be mapped to one template file directly, which is called as View First. </para> <para> In Asta4D, URL mapping rules are not managed in a configuration file. The Framework provides a sort of DSL by a set of convinient APIs, which means the declaration of Asta4D's URL mapping rule is programmable and it affords much flexibility than the way with a static configuration file. </para> <para> Users declare their own URL rules via implementing the interface UrlMappingRuleInitializer of Asta4D: </para> <example><title>Sample of declaring url rules:</title> <programlisting language="java"> <![CDATA[ public class UrlRules implements UrlMappingRuleInitializer { @Override public void initUrlMappingRules(UrlMappingRuleHelper rules) { //@formatter:off rules.add(GET, "/") .redirect("/app/index"); rules.add(GET, "/redirect-to-index") .redirect("p:/app/index"); rules.add("/app/", "/templates/index.html"); rules.add("/app/index", "/templates/index.html"); rules.add("/app/{name}/{age}", "/templates/variableinjection.html"); ... //@formatter:on } } ]]> </programlisting> </example> </section> <section id="url-rule-grammer"> <title>The grammer of URL rule and path variable</title> <para> The grammer of Asta4D's URL rule is almost the same as Spring MVC's URL mapping rule and the parts surrounded by braces are treated as path variables which can be retrieved in following process(in snippet classes or request handlers). </para> <para> Further, extra path variables can be declared in a url rule by calling the method of "var" as following: </para> <example><title>Sample of declaring extra path variable:</title> <programlisting language="java"> <![CDATA[ rules.add("/app/{name}/{age}", "/templates/variableinjection.html") .var("extraVar", 1234); ]]> </programlisting> </example> </section> <section id="variable-injection"> <title>Variable Injection</title> <para> Asta4D implements a variable injection mechanism which is very closed to Spring MVC, all of the instance fields and method parameters in the implementation of snippet classes can be injected automatically by framework. </para> <para> Further, all the snippet classes are singleton in request scope.In other words, there will be only one istance of any snippet class in a single request scope regardless of how many times the snippet class is called. Let us see some samples of variable injection in the snippet class. </para> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { @ContextData private String value; // (1) private long id; private String resolvedValue; private int count = 0; } ]]> </programlisting> <para> @ContextData indicates that the instance field "value" need to be injected after the instance of InitSnippet is created. Since the snippet instance is singeleton in the current request scope, the instance field "value" will be injected and initialized only once in the current request scope. The framework will search a variable named "value" in all the available variable scopes and inject the found value. The name of "value" is decided by the field name by default and can be sepcified by extra declaration(see the following samples). </para> </example> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { @ContextData private void setId(long id) { //(3) this.id = id; } } ]]> </programlisting> <para>Instance field can be injected via setter methods too.</para> </example> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { @Override public void init() throws SnippetInvokeException { //(2) resolvedValue = value + "-resolved"; count++; } } ]]> </programlisting> <para> The init method of InitializableSnippet is being implemented. This is not necessary but if a snippet class implements the interface of InitializableSnippet, the init method will be called once after all the instance fields are injected, by which customized snippet initial logic can be performed. </para> </example> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { // (4) public Renderer getPathVarName( @ContextData(scope = WebApplicationContext.SCOPE_PATHVAR) int count) { } } ]]> </programlisting> <para> Variable injection on snippet method. In this sample the extra search scope are delcared, which cause framework searches a variable named "count" in the path variable scope. As the same as the injection on instance field, the searching variable name is decided by the parameter name by default. </para> </example> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { // (5) public Renderer getQueryParamName( @ContextData(name = "var", scope = WebApplicationContext.SCOPE_QUERYPARAM) String name) { } } ]]> </programlisting> <para> In this sample, an extra variable name and search scope are declared, the framework will search a variable named "var" in the request parameters. </para> </example> <example> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { // (6) public Renderer getDefaultName(String name) { } } ]]> </programlisting> <para> There is a difference between instance field injection and method parameter injection. A instance field without @ContextData annotation will not be injected, but for method paramters, all the paramters will be injected compulsorily. In this sample, the framework will search a variable named "name" in all the available scopes as following order: </para> <orderedlist> <listitem> <para>HTML tag attribution(SCOPE_ATTR)</para> <para>Trace back to the top tag of the current HTML document recursively. This scope is only available to the snippet method.</para> </listitem> <listitem> <para>path variable(SCOPE_PATHVAR)</para> </listitem> <listitem> <para>request parameter(SCOPE_QUERYPARAM)</para> </listitem> <listitem> <para>flash variable(SCOPE_FLASH)</para> <para>The variables passed from one request to another request, usually acrross a redirect.</para> </listitem> <listitem> <para>cookie(SCOPE_COOKIE)</para> </listitem> <listitem> <para>request hearder(SCOPE_HEADER)</para> </listitem> <listitem> <para>request attribute(SCOPE_REQUEST)</para> </listitem> <listitem> <para>session(SCOPE_SESSION)</para> </listitem> <listitem> <para>global(SCOPE_GLOBAL)</para> <para>A global static variable pool</para> </listitem> </orderedlist> <para> This search order is applied to the instance field injection too except that the first scope of HTML tag attribution is not available. </para> </example> </section> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,674,710,467,428,987,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="renderer" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Renderer: easy to use, secure, testable</title> <section id="split-rendering"> <title>Split rendering logic from template</title> <para> There is no dynamic code in a template file. An Asta4D template file is always a pure HTML file which can be easily maintained by front-end developers, it is very design friendly and we can reduce the workload for source refactoring by over 90%. </para> <itemizedlist> <listitem> <para>Declare snippet class in template file</para> <example><title>Sample of snippet declaration:</title> <programlisting language="xml"> <![CDATA[ <section> <article> <div afd:render="SimpleSnippet">dummy text</div> <afd:snippet render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> </article> </section> ]]> </programlisting> </example> <para> The "afd:render" attribute in div tag declares a Java class which is in charge of the concrete rendering logic, such Java class is usually called as a snippet class. A snippet class can be declared by a "afd:snippet" tag too, as you have seen in above sample. The rendering logic is secluded to independent Java classes by snippet declaration and it is not necessary to learn any new template language for back-end developers. The back-end guys can achieve all the rendering logic easily by powerful Java language which they have been adept to, no learning costs, no magic codes, succinct Java source only. </para> <sbr/> </listitem> <listitem> <para>Implement a snippet class</para> <example><title>Sample of snippet class:</title> <programlisting language="java"> <![CDATA[ public class SimpleSnippet { public Renderer render(String name) { if (StringUtils.isEmpty(name)) { name = "Asta4D"; } return Renderer.create("div", name); } public Renderer setProfile() { Renderer render = Renderer.create(); render.add("p#name span", "asta4d"); render.add("p#age span", 20); return render; } } ]]> </programlisting> </example> <para> The Renderer class is provided by framework to declare rendering actions. Renderer uses traditional CSS selector to reference the rendering target and receive the rendering value at the same time, amazing and powerful. </para> <sbr/> <para>If the above template file and snippet class are executed, we would get the following result:</para> <example><title>Result of snippet execution:</title> <programlisting language="xml"> <![CDATA[ <section> <article> <span>Hello Asta4D</span> <p id="name">name:<span>asta4d/span></p> <p id="age">age:<span>20</span></p> </article> </section> ]]> </programlisting> </example> </listitem> </itemizedlist> <para> Asta4D introduces 4 extra tags to the html template file: afd:extension, afd:block, afd:embed, afd:snippet, which will not disturb most html editors, accordingly Asta4D is extremely friendly to front-end engineers. On the other hand, we can see that all the rendering logic is fulfiled by Java code and the back-end engineers can compose their back-end logic and rendering logic very smoothly without magic skills and extra learning costs, which means highly boost of productivity. </para> </section> <section id="render-to-page"> <title>Render data to page</title> <remark>Be careful of "ElementUtil.parseAsSingle" which would cause cross-site issues. Basically the parseAsSingle api is not recommended for common use. See more at<xref linkend="immune-from-xss"/>.</remark> <itemizedlist> <listitem> <para>In Asta4D, all the rendering logic is declared by a Renderer class which accepts various types as rendering value.</para> <example><title>Sample usage of Renderer</title> <programlisting language="java"> <![CDATA[ Renderer render = Renderer.create(); render.add("#someIdForInt", 12345); render.add("#someIdForLong", 12345L); render.add("#someIdForBool", true); render.add("#someIdForStr", "a str"); render.add("#someIdForNull", (Object) null); render.add("#someIdForClear", Clear); // NOTE: parseAsSingle is not recommended to use Element newChild = ElementUtil.parseAsSingle("<div></div>"); render.add("#someIdForElementSetter", new ChildReplacer(newChild)); render.add("#someIdForElement", ElementUtil.parseAsSingle("<div>eee</div>")); render.add("#someIdForRenderer", Renderer.create("#value", "value")); ]]> </programlisting> </example> </listitem> <listitem> <para>List of data can be rendered via Renderer too:</para> <example><title>Sample of list rendering</title> <programlisting language="java"> <![CDATA[ Renderer render = Renderer.create()(); render.add("#someIdForInt", Arrays.asList(123, 456, 789)); render.add("#someIdForLong", Arrays.asList(123L, 456L, 789L)); render.add("#someIdForBool", Arrays.asList(true, true, false)); render.add("#someIdForStr", Arrays.asList("str1", "str2", "str3")); // NOTE: parseAsSingle is not recommended to use Element newChild1 = ElementUtil.parseAsSingle("<div>1</div>"); Element newChild2 = ElementUtil.parseAsSingle("<div>2</div>"); render.add("#someIdForElementSetter", Arrays.asList(new ChildReplacer(newChild1), new ChildReplacer(newChild2))); render.add("#someIdForElement", Arrays.asList(newChild1, newChild2)); render.add("#someIdForRenderer", Arrays.asList(123, 456, 789), new RowRenderer<Integer>() { @Override public Renderer convert(int rowIndex, Integer obj) { return Renderer.create("#id", "id-" + obj).add("#otherId", "otherId-" + obj); } }); ]]> </programlisting> </example> </listitem> <listitem> <para>DOM attribution can be done too:</para> <example><title>Sample of DOM attribution rendering</title> <programlisting language="java"> <![CDATA[ render.add("#id", "+class", "yyy"); render.add("#id", "-class", "zzz"); render.add("#id", "+class", "xxx"); render.add("#id", "value", "hg"); render.add("#id", "href", null); render.add("#X", "value", new Date(123456L)); ]]> </programlisting> </example> </listitem> </itemizedlist> </section> <section id="immune-from-xss"> <title>Immune from cross-site hole</title> <para> The previous samples show us that all the operations to DOM are delegated by Renderer except create DOM from String value by "ElementUtil#parseAsSingle". As a matter of fact, all the delegated operations cause all the rendering values are escaped by force, which means that your system is, by nature, immune from cross-site problems if there is no "ElementUtil#parseAsSingle" calling in your system. You do not need to be wary of illegal characters by from the clients since all the values will be escaped as HTML compulsorily. </para> On the other hand, according to our practice, it is rarely that you have to call “ElementUtil.parseAsSingle” to generate the rendering content from a raw HTML string, so just take care of your usage of this exceptional api then you can say bye-bye to the cross-site holes. </section> <section id="test-rendering"> <title>Test your rendering logic</title> <para> Testing web page is always a complex task and we usually verify rendering results by selenuim which is as a common technology. By Asta4D, testable Renderer can replace over than half of selenium tests to simpler junit tests. </para> <para> According to the previous samples, all the rendering logic is holded by an instance of Renderer class, so simply, we can verify almost rendering logic by testing the returned Renderer instance from the snippet method. </para> <example><title>Sample RendererTester</title> <programlisting language="java"> <![CDATA[ RendererTester tester = RendererTester.forRenderer(render); Assert.assertEquals(tester.get("#someIdForInt"), 12345); Assert.assertEquals(tester.get("#someIdForLong"), 12345L); Assert.assertEquals(tester.get("#someIdForBool"), true); Assert.assertEquals(tester.get("#someIdForStr"), "a str"); Assert.assertEquals(tester.get("#someIdForNull"), null); Assert.assertEquals(tester.get("#someIdForClear"), Clear); ]]> </programlisting> <para>More samples can be found in <ulink url="https://github.com/astamuse/asta4d/blob/develop/asta4d-core/src/test/java/com/astamuse/asta4d/test/unit/RenderTesterTest.java">source</ulink></para> </example> </section> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,078,908,166,451,889,700
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-integration-spring" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Integration with Spring</title> <sect1 id="integrate-spring-ioc"> <title>Integrate with Spring IOC</title> <para>Asta4D can be integrated with any dependency injection mechanism. We will introduce how to integrate with Spring IOC as example.</para> <para>There is a package called asta4d-spring which supplies reference implementation to show how to integrate a DI container to Asta4D. Firstly, as an alternative for Asta4dServlet introduced in the previous chapter, SpringInitializableServlet can be used to initialize Spring configuration automatically. The web.xml file should be like following:</para> <example> <programlisting language="xml"> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- integrate with spring --> <servlet> <servlet-name>Asta4D Servlet</servlet-name> <servlet-class>com.astamuse.asta4d.misc.spring.SpringInitializableServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/configuration.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Asta4D Servlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> ]]> </programlisting> </example> <para>Secondly, the WebApplicationConfiguration instance should be declared as a bean in spring with additional Spring special configurations:</para> <example> <programlisting language="xml"> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <bean id="asta4dConfiguration" class="com.astamuse.asta4d.web.WebApplicationConfiguration"> <property name="snippetResolver"> <bean class="com.astamuse.asta4d.misc.spring.SpringManagedSnippetResolver"> <property name="searchPathList"> <list> <value>com.foo.web.snippet</value> </list> </property> </bean> </property> <property name="instanceResolverList"> <list> <bean class="com.astamuse.asta4d.misc.spring.SpringManagedInstanceResolver"/> </list> </property> </bean> ]]> </programlisting> <remark>The SpringManagedSnippetResolver will retrieve snippet instance from Spring container and the SpringManagedInstanceResolver will also retrieve request handler instance from Spring container. Further the SpringManagedSnippetResolver will treat the snippet name in html template files as bean id.</remark> </example> <para>The following example shows a full image of Spring's configuration for Asta4D:</para> <example> <programlisting language="xml"> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <bean id="asta4dConfiguration" class="com.astamuse.asta4d.web.WebApplicationConfiguration"> <property name="snippetResolver"> <bean class="com.astamuse.asta4d.misc.spring.SpringManagedSnippetResolver"/> </property> <property name="instanceResolverList"> <list> <bean class="com.astamuse.asta4d.misc.spring.SpringManagedInstanceResolver"/> </list> </property> <property name="pageInterceptorList"> <list> <bean class="com.astamuse.asta4d.sample.interceptor.SamplePageInterceptor"/> </list> </property> <property name="snippetInvoker"> <bean id="snippetInvoker" class="com.astamuse.asta4d.snippet.DefaultSnippetInvoker"> <property name="snippetInterceptorList"> <list> <bean class="com.astamuse.asta4d.sample.interceptor.SampleSnippetInterceptor"/> </list> </property> </bean> </property> <property name="urlMappingRuleInitializer"> <bean class="com.astamuse.asta4d.sample.UrlRules"/> </property> </bean> <bean id="ComplicatedSnippet" class="com.astamuse.asta4d.sample.snippet.ComplicatedSnippet" scope="prototype"/> <bean id="FormSnippet" class="com.astamuse.asta4d.sample.snippet.FormSnippet" scope="prototype"/> <bean id="SimpleSnippet" class="com.astamuse.asta4d.sample.snippet.SimpleSnippet" scope="prototype"/> <bean id="ShowCodeSnippet" class="com.astamuse.asta4d.sample.snippet.ShowCodeSnippet" scope="prototype"/> <bean class="com.astamuse.asta4d.sample.handler.LoginHandler"/> ]]> </programlisting> <remark>Note that Asta4D always treats snippet instance as singleton per request for field injection on snippet, so the scope of snippet beans should be "prototype" basically except there is no field injection in snippet implementation. For the request handlers, "prototype" is not necessary since there is no field injection on request handler.</remark> </example> </sect1> <sect1 id="integrate-spring-mvc"> <title>Integrate with Spring MVC</title> <para>Asta4D's template engine can be integrated to Spring MVC as view solution too. The following configuration shows how:</para> <example> <programlisting language="xml"> <![CDATA[ <bean id="asta4dConfiguration" class="com.astamuse.asta4d.web.WebApplicationConfiguration"> <property name="snippetResolver"> <bean class="com.astamuse.asta4d.misc.spring.SpringManagedSnippetResolver"> <property name="searchPathList"> <array> <value>com.foo.web.snippet</value> </array> </property> </bean> </property> <property name="cacheEnable" value="false"/> </bean> <bean class="com.astamuse.asta4d.misc.spring.mvc.SpringWebPageViewResolver"> <property name="prefix" value="/templates"/> <property name="suffix" value=".html"/> </bean> <mvc:interceptors> <bean class="com.astamuse.asta4d.misc.spring.mvc.Asta4dContextInitializeHandlerInterceptor"/> </mvc:interceptors> ]]> </programlisting> </example> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-36,974,205,588,602,456
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-adv-request-handler" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Advanced usage of request handler</title> <para>This chapter is to show how you can make advanced usage of request handler on various situations.</para> <sect1 id="advanced-mvc"> <title>Advanced MVC architecture</title> <para>Even we emphasize that Asta4D is a view first framework, it is still compatible with MVC architecture. Further, we would say that Asta4D affords an advanced MVC architecture than traditional MVC frameworks by the view first mechanism.</para> <para>In the MVC theory, a controller would act as multi roles in a full request process, from wikipedia, it says: <remark>"A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document)."</remark> But those are not all in most situations, we usually have to do more things in a controller such as querying additional assistant data for page rendering.</para> <para>By traditional MVC architecture, we often have to expand the transaction from the controller layer across to the view layer to combat the lazy load issue, which ugly structure is essentially caused by the tangled controller which holds various unrelated duties.</para> <para>It is also strange that we have to modify our controller's implementation at every time we change the page appearance at view layer. Such situation could not satisfy us since the layers are not uncoupled really.</para> <para>We would say that the traditional controller is indeed a tangled magic container for most logics, a controller will unfortunately be coupled to most layers in the system even our initial purpose of MVC is to uncouple our logics. By contrast, Asta4D allows developers to really uncouple all the tangled logics easily. Basically we could split the traditional controller's duty to following parts:</para> <itemizedlist> <listitem> <para>request handler</para> <para>Which takes the responsibilities of all the operations with side-effect.</para> </listitem> <listitem> <para>result matching in url rule</para> <para>Which dispatches the request to different views according to the result from request handler</para> </listitem> <listitem> <para>snippet class</para> <para>Which has the responsibility to render data to the page and also holds the obligation of preparing all the necessary data for page rendering.</para> </listitem> </itemizedlist> <para>By above architecture, we could perfectly uncouple our logics by clarifying the obligation of each layer.</para> <remark>Need sample source ...</remark> </sect1> <sect1 id="normalize-page-url"> <title>Normalize page url patterns</title> <para>Commonly, we would probably have multiple path patterns for the same template file but we would hope our snippet implementation could deal with a unified pattern, which can be simply achieved by a request handler.</para> <example> <title>Normalize page url</title> <programlisting language="java"> <![CDATA[ rules.add("/user/name/{name}").id("user-page") rules.add("/user/{id}").id("user-page") .handler(new Object(){ @RequestHandler public void preparePage(Context context, Integer id, String name){ User user = null; if(id != null){ user = queryUserById(id); }else if (name != null){ user = queryUserByName(name); } if(user != null){ //in the snippet class, a @ContextData annotation can by use to retrieve this value by injection context.setData("user-page-condition", user); } } }).forward("/user-page.html"); ]]> </programlisting> <remark>Somebody would argue that the above example is apparently a traditional MVC architecture, that is right or wrong. For the most simple situation, if the snippet class will only show the data from entity class User without any extra query, it is true that the above source shows a traditional MVC architecture. But for the most situations, the page rendering would require more additional queries, which would be done at the snippet side. Such structure is so far from the traditional MVC that we would rather to call it as view first.</remark> </example> <para>In the above example, we do not cope with the case of user does not exist. The following source shows how we can cope with such situation: </para> <example> <title>Normalize page url and PageNotFoundException</title> <programlisting language="java"> <![CDATA[ rules.addGlobalForward(PageNotFoundException.class, "/template/PageNotFound.html", 404); rules.addGlobalForward(Throwable.class, "/template/UnknownError.html", 500); rules.add("/user/name/{name}").id("user-page") rules.add("/user/{id}").id("user-page") .handler(new Object(){ @RequestHandler public void preparePage(Context context, Integer id, String name){ User user = null; if(id != null){ user = queryUserById(id); }else if (name != null){ user = queryUserByName(name); } if(user == null){ throw new PageNotFoundException(); }else //in the snippet class, a @ContextData annotation can by use to retrieve this value by injection context.setData("user-page-condition", user); } } }).forward("/user-page.html"); ]]> </programlisting> </example> <para>See more details at <xref linkend="normalize-page-condition"/></para> </sect1> <sect1 id="rest-ajax"> <title>Restful and ajax</title> <para>For the request which does not require response of html files, such as restful or ajax request, request handler can be used to cope with such situation.</para> <para>There is a rest() method which does nothing on the current rule by default but can be used as a hint to suggest that the current rule will response customized contents as a restful api. A request handler can return a ContentProvider to supply customized response content. Details of ContenProvider can be found at later chapters, here we only show examples of how to response customized contents.</para> <example> <title>Return header only response</title> <programlisting language="java"> <![CDATA[ public class UpdateHandler { @RequestHandler public ContentProvider doUpdate(String id, String content) { if (idExists(id)) { try { updateContent(id, content); return new HeaderInfoProvider(); } catch (Exception ex) { HeaderInfoProvider header = new HeaderInfoProvider(500); header.addHeader("exception", ex.getMessage()); return header; } } else { return new HeaderInfoProvider(404); } } } ]]> </programlisting> </example> <example> <title>Return customized binary data</title> <programlisting language="java"> <![CDATA[ public class GetHandler { @RequestHandler public ContentProvider get(String id) { Object data = getContent(id); if (data == null) { return new HeaderInfoProvider(404); } else { HeaderInfoProvider header = new HeaderInfoProvider();// default to 200 header.addHeader("Content-Type", "application/json"); String json = toJson(data); BinaryDataProvider binaryData = new BinaryDataProvider(json.getBytes()); return new SerialProvider(header, binaryData); } } } ]]> </programlisting> </example> <para>For json data, there is a more convenience way to response a json string to client. A json() method can be used on rule declaration to ask the framework to convert the returned result from request handler to a json string automatically. the above </para> <example> <title>Declare json at rule</title> <programlisting language="java"> <![CDATA[ // in rule declaration rules.add("/get").handler(GetHandler.class).json(); //the handler implementation public class GetHandler { @RequestHandler public Object get(String id) { return getContent(id); } } ]]> </programlisting> </example> <remark>By default, a rest rule will do nothing on the result of handler and a ContentProvider instance is expected, by contrast, there is a built-in json transformer for rules which are declared as json. However, developers can still register a customized result transformer for rest rules or even register a customized json transformer to override the default built-in implementation. See details at <xref linkend="UrlMappingRuleInitializer"/></remark> <para>Further, since a request handler can access HttpServletResponse instance directly, developer can do more complex customization on HttpServletResponse instance directly.</para> <example> <title>access HttpServletResponse directly</title> <programlisting language="java"> <![CDATA[ public class XXXHandler { @RequestHandler public void handle(HttpServletResponse response) throws IOException { response.setStatus(200); response.addHeader("xxx", ""); response.getOutputStream().write("OK".getBytes()); } } ]]> </programlisting> </example> <para>There are two built-in customized request handlers for handler static resouce files and mapping generic path template files. See the next section.</para> </sect1> <sect1 id="handle-static-resource"> <title>Handle static resouce files</title> <para>The most simple way to handling static resource files is mapping their path in web.xml then they will be serviced by the servlet container. But Asta4D still affords a way to handle them at framework level.</para> <example> <title>handler static files</title> <programlisting language="java"> <![CDATA[ rules.add("/js/**/*").handler(new StaticResourceHandler()); rules.add("/img/**/*").handler(new StaticResourceHandler("/resource/img")); rules.add("/favicon.ico").handler(new StaticResourceHandler(/img/favicon.ico)); ]]> </programlisting> </example> <para>The wild-card "/**/*" in source path is necessary if you want to mapping all the urls with same path prefix to a certain base folder. The base path parameter in constructor of StaticResourceHandler is not necessary. if the base path is not specified, StaticResourceHandler will treat the part before the wild-card "/**/*" in source path as the base path. </para> <para>StaticResourceHandler can be customized by path var configuration or overriding some protected methods by extending. See details in javadoc of StaticResourceHandler.</para> <example> <title>customize StaticResourceHandler</title> <programlisting language="java"> <![CDATA[ // by path var rules.add("/js/**/*") .var(StaticResourceHandler.VAR_CONTENT_TYPE, "text/javascript") .handler(StaticResourceHandler.class); // by overring rules.add("/js/**/*").handler(new StaticResourceHandler(){ @Override protected long decideCacheTime(String path) { return 24 * 60 * 60 * 1000; //force cache 24 hours } }); ]]> </programlisting> <para>Note that it is not necessary to specify content type for most situations because StaticResourceHandler will guess the content type by file name extension automatically.</para> </example> </sect1> <sect1 id="handle-generic-path"> <title>Handle generic path template files</title> <para>Basically Asta4D asks developers to declare the matching relationship between url and template file one by one, but it still allows to declare a generic path matching for all files in same folder, which can be achieved by GenericPathTemplateHandler.</para> </sect1> <example> <title>handler template files in bulk</title> <programlisting language="java"> <![CDATA[ rules.add("/pages/**/*").handler(GenericPathTemplateHandler.class); ]]> </programlisting> <para>As same as the StaticResourceHandler, the wild-card "/**/*" is necessary and the base path parameter of constructor can be ignored.</para> </example> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
3,292,487,747,464,762,400
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="overview" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Overview of Asta4D</title> <para>Asta4D is inspired by lift which is a famous scala web application framework. Asta4D is therefore developed as an alternative of lift for Java. If you like scala, we strongly recommend lift for you and if you‘d like to enjoy the benefit of lift while still staying with Java, we believe our Asta4D is your best fit.</para> <para>In the past decade, plenty of Java based web application frameworks are generated. Especially the MVC architecture and JSP tag libs (or other traditional template technologies) that has greatly released our productivity. But unfortunately, we are still suffering from the following situations: </para> <itemizedlist> <listitem> <para>The designers or front-end engineers are keeping complaining the mixed-in dynamic code, as they disturb their efforts of redesigning the page style or structure. And in the mean time, the back-end developers are also complaining that the front-end guys break the working page frequently, because redesign or the new design is hard to merge due to the huge cost of source refactoring. </para> </listitem> <listitem> <para>The developers are complaining about the poor functionalities of template language which they are using and tired from the various magic skills for complex rendering logic.</para> </listitem> <listitem> <para>3. The developers are discontented with the counterproductivity of MVC architecture and desire a more efficient approach like traditional PHP/ASP development.</para> </listitem> </itemizedlist> <para>Asta4D is our solution to combat those issues. Thanks to lift, from where we learn a lot, and try to bring them into the Java’s world. We designed Asta4D complying with the following points: </para> <itemizedlist> <listitem> <para>Separate template and rendering logic</para> <para>There is no dynamic code in template file. An Asta4D template file is always a pure HTML file which can be easily maintained by front-end developers, it is very design friendly and we can reduce the workload for source refactoring by over 90%. </para> <programlisting language="php"> <![CDATA[ <section> <article> <div afd:render="SimpleSnippet">dummy text</div> <afd:snippet render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> </article> </section> ]]> </programlisting> <para>The rendering logic is secluded to an independent java class, developers do not need to learn any new template language, they can continue to use their familiar Java to describe how they want to render the page with the full power of Java language. </para> <programlisting language="java"> <![CDATA[ public class SimpleSnippet { public Renderer render(String name) { if (StringUtils.isEmpty(name)) { name = "Asta4D"; } Element element = ElementUtil.parseAsSingle("<span>Hello " + name + "!</span>"); return Renderer.create("*", element); } public Renderer setProfile() { Renderer render = new GoThroughRenderer(); render.add("p#name span", "asta4d"); render.add("p#age span", "20"); return render; } } ]]> </programlisting> </listitem> <listitem> <para>View first without controller and a powerful and easy to use URL matching mechanism</para> <para>We agree with that MVC is a great and powerful architecture, but it is counterproductive. For years, Java programmers have been desiring for a solution that is efficient to develop like traditional PHP/ASP development. The essential reason of why traditional PHP/ASP development is efficient is the answer called “View First”. In a view first developing style, a developer will implement the logic at where the result is supposed to be shown, which is how the traditional PHP/ASP development performs. </para> <para>Many people would argue that the implementation on site will cause the source becomes more complex and hard to understand. This is not wrong, but we have separated our template file from rendering logic, so it is no longer a problem. In terms of productivity, the developers can therefore concentrate on the real development without worrying about complicating source structure. </para> <para>We also supply a powerful and easy way to configure URL matching rules with a sort of human friendly configuration api.</para> <programlisting language="java"> <![CDATA[ rules.add("/app/", "/templates/index.html"); rules.add("/app/handler") .handler(LoginHandler.class) .handler(EchoHandler.class) .forward(LoginFailure.class, "/templates/error.html") .forward("/templates/success.html"); ]]> </programlisting> </listitem> <listitem> <para>Simple but flexible process flow</para> <para>There is no controller in our framework, we believe there should be a certain party which should take the responsibility of a certain request, we called the certain party as request handlers. We assume that a sort of request handlers will try to supply certain content to the client who sends the request, so a request handler will supply a content provider which will produce the real content and then a content writer will take the obligation of writing the content back to the client.</para> <para>Thus, an ajax or Restful request can be simply forwarded to a request handler which will supply the result. </para> <para>JSON:</para> <programlisting language="java"> <![CDATA[ rules.add("/app/ajax/getUserList").handler(GetUserListHandler.class).json(); //... public class GetUserListHandler { @RequestHandler public List<String> queryUserList() { return Arrays.asList("otani", "ryu", "mizuhara"); } } ]]> </programlisting> <para>Restful:</para> <programlisting language="java"> <![CDATA[ rules.add(PUT, "/app/ajax/addUser").handler(AddUserHandler.class).rest(); //... public class AddUserHandler { @RequestHandler public HeaderInfo doAdd(String newUserName) { // some logic that should add a new user by the given name // ... return new HeaderInfo(200); } } ]]> </programlisting> </listitem> <listitem> <para>Isolate side effect with request handler and multi-threaded page rendering</para> <para>There are two types of action in a system, one is with “side effect”, another one is without “side effect”. “actions with side effect” are ones that will change the system status once they are performed. For instance, for the same URL, a login request (if succeeded) will cause a client’s privilege to be changed and the client could probably get a different page view from what the client get before login, because of which we say a login request is an action with side effect. Another obvious example is a database update operation. Once an update is committed, all the related clients will get a different output from the result before the update, which is also classified as “an action with side effect”. How about a query? We consider a query as an operation without side effect, it means that a client will always get the same result regardless of how many times the query is executed.</para> <para>We believe the actions with side effect should be managed seriously and we do that by putting all the actions with side effect to request handlers so that the view layer is purified and this makes the source more clear and maintainable. This is also means with Asta4D we can easily perform multi thread rendering on a single page because they are now all side-effect free. </para> <para>paralle snippet rendering:</para> <programlisting language="php"> <![CDATA[ <div afd:render="ParallelTest$TestRender:snippetInDiv" afd:parallel> <div id="test">xx</div> </div> <afd:snippet render="ParallelTest$TestRender:snippetReplaceDiv" parallel> <div id="test">xx</div> </afd:snippet> ]]> </programlisting> <para>parallel list rendering:</para> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create("div#test", list, new ParallelDataConvertor<String, String>() { @Override public String convert(String obj) { try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } return obj + "-sleep"; } }); ]]> </programlisting> </listitem> </itemizedlist> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,357,388,419,728,120,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-Inheritable-template" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Flexible template</title> <section id="inheritable-template"> <title>Inheritable template</title> <para> The template of Asta4D is inheritable, child template can override, append or insert content to certain place in parent template. Let's see a sample: </para> <example><title>parent.html</title> <programlisting language="xml"> <![CDATA[ <html> <head> <afd:block id="block1"> <link href="parent1.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block id="block2"> <link href="parent2.css" rel="stylesheet" type="text/css" /> </afd:block> <title>extension sample</title> </head> <body> <afd:block id="content">content</afd:block> </body> </html> ]]> </programlisting> </example> <para>Child template can declare inheritance by "afd:extension" and overriding can be declared by "afd:block":</para> <example id="template-child"><title>child.html</title> <programlisting language="xml"> <![CDATA[ <afd:extension parent="parent.html"> <afd:block append="block1"> <link href="child1.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block insert="block2"> <link href="child2.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block override="content "> <div>hello</div> <afd:embed target="/templates/embed.html" ></afd:embed> </afd:block> </afd:extension> ]]> </programlisting> </example> <para> "afd:block" support 3 types action: insert, append and override. </para> <sbr/> <para> In the <xref linkend="template-child"/>, there is an additional declaration of including by "afd:embed" which embed the target file to the current place of the current file. Let's see the embed.html: </para> <example><title>embed.html</title> <programlisting language="xml"> <![CDATA[ <afd:block append="block1"> <link href="embed.css" rel="stylesheet" type="text/css" /> </afd:block> <div>good embed</div> ]]> </programlisting> </example> <para> The "afd:block" declaration in the embeded target file is available after the content of target file is inserted into the <xref linkend="template-child"/>, all "afd:block" tags will be treated as overriding(inserting/appending) to the parent template and the contents out of "afd:blocks" will be inserted at the place where the "afd:embed" is declared. </para> <sbr/> <para>After all the template files are merged, we will get the following result:</para> <example><title>The result of template merging:</title> <programlisting language="xml"> <![CDATA[ <html> <head> <!-- block1 --> <link href="parent1.css" rel="stylesheet" type="text/css" /> <link href="child1.css" rel="stylesheet" type="text/css" /> <link href="embed.css" rel="stylesheet" type="text/css" /> <!-- block2 --> <link href="child2.css" rel="stylesheet" type="text/css" /> <link href="parent2.css" rel="stylesheet" type="text/css" /> <title>extension sample</title> </head> <body> <!-- content --> <div>hello</div> <!-- embed --> <div>good embed</div> </body> </html> ]]> </programlisting> </example> </section> <section id="parametrized-embedding"> <title>Parametrized embedding</title> <para> Extra parameters can be passed to the target embeded file by specifying the DOM attribute of "afd:embed" when we are embeding files. </para> <example><title>Sample of parametrized embeding:</title> <programlisting language="xml"> <![CDATA[ <afd:embed target="/xxx/showList.html" limit="30"></afd:embed> ]]> </programlisting> </example> <para> The "limit" parameter can be accessed by variable injection in the rendering logic of showList.html, by which we can parameterize the embeding. This feature is very useful for creating a page component which encapsulates common html snippets and can be controlled by the passed parameters. Basically, embeding a file in a template file is similar to calling a function with(or without) arguments. Especially, the parameters are not limited to specified static values in the template file, they can be valued dynamicaly at runtime too. Further, the type of parameters is not restricted to the stringizable types such as String or Integer/Long, arbitrary Java type can be specified dynamically at runtime. See the reference of Renering logic to learn more details. </para> </section> <para> Simply, the idea of Asta4D's template system is akin to the traditional OOP model, the parent and child templates can be regarded as parent/child classes and the block can be viewed as a overridable virtual method. The embed external files can be also treated as funcation calling. As a matter of fact, since arbitrary type of value can be passed to the embed files, there is actually no difference between Asta4D's embeding and common function calling. </para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-2,817,212,488,971,195,400
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-side-effect" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Side effect and request handler</title> <section> <title>The role with responsibility to http request: Request Handler</title> <para> Even Asta4D complies with the principle of view first, there is still a role similar with the controller in MVC architecture, such role is called request handler. We believe that there should be a role who takes responsiblity of a certain http request and such role can be considered as an alternative to controller of MVC in some situations too. </para> <para> According to the view first rule, a request handler can be ignored in most cases. You can also assume that there is is a default request handler which navigates all the http requests to the corresponding template files(The real story is more complex but you can try to understand the theory conceptually by this way). </para> <para> Now the question is when we need a request handler? Before we can answer this question, we have to discuss the conception of "side effect". </para> </section> <section> <title>Side effect of system operations</title> <para> A system always afford users various operations such as query, update, etc. All of these operations will affect the status of system in various ways. In Asta4D, we say that there are two types of action in a system, one is with “side effect”, another one is without “side effect”. “actions with side effect” are ones that will change the system status once they are performed. For instance, for the same URL, a login request (if succeeded) will cause a client’s privilege to be changed and the client could probably get a different page view from what the client get before login, because of which we say a login request is an action with side effect. Another obvious example is a database update operation. Once an update is committed, all the related clients will get a different output from the result before the update, which is also classified as “an action with side effect”. </para> <para> How about a query? We consider a query as an operation without side effect, it means that a client will always get the same result regardless of how many times the query is executed. Some people may ask how about counting on query times? For counting on query times, we can still split the counting and query to two individual operations, one is with side effect and another one is without side effect. </para> </section> <section> <title>Isolate side effect and multi thread rendering</title> <para> We believe the actions with side effect should be managed seriously and we do that by putting all the actions with side effect to request handlers so that the view layer is purified and this makes the source more clear and maintainable. This is also means with Asta4D we can easily perform multi thread rendering on a single page because they are now all side-effect free, which is a high light function of Asta4D. </para> <para> In traditional MVC architecture, the responsibility of controller is tangled, a controller does not only handle the duty of altering system status(date update), but also takes the responsibility of preparing data for view layer. We often have to expand the database session(transaction) to the view layer for handling lazy load issue, which makes transaction management more complicated. Additionally, especially for the pages that can be split to relatively individual blocks, hypothetically we can accelerate the page loading by retrieving data in multi threads for each block, but in reality it is impossible due to the source complexity and development costs. The developers still have to access each data source sequentially to retrieve data for each block even the page is splitable as individual blocks. </para> <para> For Asta4D, the logic layers of system is clarified by isolating side effects at architecture level. The database session(transaction) does no longer need keep opening cross layers, it is clear that the duty of request handler is altering system status but not preparing data for view layer. At the mean time, at the view layer, acquiring data and rendering data are performed at the same time, at the same place: We access data source and retrieve data in snippet method, and pass the data to Renderer to perform rendering immediately in the same snippet method. Further, the complexity can be reduced drastically because all the accesses to certain data are isolated in certain snippet methods and there is no cross layer invoking and coupling any more. </para> <para> On the other hand, we can simply perform multi thread rendering by calling each snippet method in different threads, which is transparent to developer. Because all the side effects has been isolated in request handler layer, we do not need to considerate sync or mutex even we are performing multi thread rendering since the view layer is side effect free now. </para> <para> Let us see how easy we can achieve parallel rendering </para> <example> <programlisting language="xml"> <![CDATA[ <div afd:render="ParallelTest$TestRender:snippetInDiv" afd:parallel> <div id="test">xx</div> </div> <afd:snippet render="ParallelTest$TestRender:snippetReplaceDiv" parallel> <div id="test">xx</div> </afd:snippet> ]]> </programlisting> <para> All the snippets declared with parallel(afd:parallel) attribution will not block the http request main thread, the http request main thread will wait for the parallel rendering after all the non-parallel rendering finished, then merge the result and output to the client. </para> </example> </section> <!-- <section> <title>Compatibility to MVC</title> <para> Someone may ask: "Is it true that we do not need MVC?", "Is it true that we do not need a controller?". The answer is "No". We admit that MVC architecture is more convenient than view first for some certain cases, for instance, when we are handling form submission, the MVC structure is required naturally. By Asta4D, you can simply handle this case by implement the request handler as a controller. </para> <para> Further, perhaps you cannot agree with the idea of view first. You believe a controller is necessary in any case but you are also interested in the split template mechanism of Asta4D, the same answer for you: implement your request handler as a controller. </para> <para> <remark>You can also integrate Asta4D's template only as a view layer implementation for Spring MVC. More details can be found in reference.</remark> </para> </section> --> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
7,521,372,203,967,404,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-snippet" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Details of snippet class</title> <sect1> <title>Rendering APIs</title> <para>Asta4D provides various rendering APIs to help developers render value to the page. By those APIs, developer can render text under a DOM element, set the attribute value for a DOM element, also can convert a list data to a list of DOM element, and also other various manipulation on DOM elements. </para> <toc/> <sect2> <title>Create and add Renderer instance</title> <para>There are almost same two sets of overloaded methods: create and add. The create methods are static and can be used to create a Renderer instance. The add methods are instance methods and can be used to add a implicitly created Renderer instance to an existing Renderer instance. Both of the create and add methods return the created Renderer instance therefore chain invoking can be performed as well.</para> <example> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create("#someId", "xyz").add("sometag", "hello"); renderer.add(".someclass", "abc").add(".someclass2", "abc2"); Renderer renderer2 = Renderer.create("#someId2", "xyz2"); Renderer renderer3 = Renderer.create("#someId3", "xyz3"); //add renderer2 and renderer3 to renderer renderer.add(renderer2); renderer.add(renderer3); ]]> </programlisting> </example> <para>Note that the order of a Renderer instance being added is significant but the target instance which a Renderer is added to has no effect on the rendering order. In the following example, "add renderer2 to renderer then add renderer3 to renderer2" is completely equal to "add renderer2 and renderer3 to renderer" at above example. </para> <example> <programlisting language="java"> <![CDATA[ //add renderer2 to renderer then add renderer3 to renderer2 renderer.add(renderer2); renderer2.add(renderer3); ]]> </programlisting> </example> <para>The following is equal too:</para> <example> <programlisting language="java"> <![CDATA[ //add renderer3 to renderer2 then add renderer2 to renderer renderer2.add(renderer3); renderer.add(renderer2); ]]> </programlisting> </example> <para>A instance of Renderer should not be considered as a single rendering declaration only, A instance of Renderer is exactly a rendering chain holder, you can call add method on any instance of the chain but the added Renderer instance will be always added to the tail of the chain. If the added Renderer instance is holding over than one Renderer instance in its own chain, the held chain will be added to the tail of the chain of the target Renderer.</para> <para>There is also a non-parameter create method which can by used to create a "do nothing" Renderer for source convenience. In our practice, we write the following line at the beginning of most of our snippet methods.</para> <example> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create(); ]]> </programlisting> </example> <para>In following sections, we will introduce add method only, but you should remember that there should be a equal create method for most cases. You can also read the Java doc of Renderer for more details.</para> </sect2> <sect2 id="css-selector"> <title>CSS Selector</title> <para>Asta4D is using a modified version of <ulink url="http://jsoup.org/">jsoup library</ulink> to afford CSS selector function. Currently, we support the following selectors: </para> <table frame='all'><title>Supported selectors</title> <tgroup cols='3' align='left' colsep='1' rowsep='1'> <colspec colname='c1'/> <colspec colname='c2'/> <colspec colname='c3'/> <thead> <row> <entry>Pattern</entry> <entry>Matches</entry> <entry>Example</entry> </row> </thead> <tbody> <row> <entry>*</entry> <entry>any element</entry> <entry>*</entry> </row> <row> <entry>tag</entry> <entry>elements with the given tag name</entry> <entry>div</entry> </row> <row> <entry>ns|E</entry> <entry>elements of type E in the namespace ns</entry> <entry>fb|name finds &lt;fb:name&gt; elements</entry> </row> <row> <entry>#id</entry> <entry>elements with attribute ID of "id"</entry> <entry>div#wrap, #logo</entry> </row> <row> <entry>.class</entry> <entry>elements with a class name of "class"</entry> <entry>div.left, .result</entry> </row> <row> <entry>[attr]</entry> <entry>elements with an attribute named "attr" (with any value)</entry> <entry>a[href], [title]</entry> </row> <row> <entry>[^attrPrefix]</entry> <entry>elements with an attribute name starting with "attrPrefix". Use to find elements with HTML5 datasets</entry> <entry>[^data-], div[^data-]</entry> </row> <row> <entry>[attr=val]</entry> <entry>elements with an attribute named "attr", and value equal to "val"</entry> <entry>img[width=500], a[rel=nofollow]</entry> </row> <row> <entry>[attr^=valPrefix]</entry> <entry>elements with an attribute named "attr", and value starting with "valPrefix"</entry> <entry>a[href^=http:]</entry> </row> <row> <entry>[attr$=valSuffix]</entry> <entry>elements with an attribute named "attr", and value ending with "valSuffix"</entry> <entry>img[src$=.png]</entry> </row> <row> <entry>[attr*=valContaining]</entry> <entry>elements with an attribute named "attr", and value containing "valContaining"</entry> <entry>a[href*=/search/]</entry> </row> <row> <entry>[attr~=regex]</entry> <entry>elements with an attribute named "attr", and value matching the regular expression</entry> <entry>img[src~=(?i)\\.(png|jpe?g)]</entry> </row> <row> <entry></entry> <entry>The above may be combined in any order</entry> <entry>div.header[title]</entry> </row> <row> <entry></entry> <entry></entry> <entry></entry> </row> <row> <entry namest="c1" nameend="c3" align='center' valign='bottom'><emphasis>Combinators</emphasis></entry> </row> <row> <entry>E F</entry> <entry>an F element descended from an E element</entry> <entry>div a, .logo h1</entry> </row> <row> <entry>E > F</entry> <entry>an F direct child of E</entry> <entry>ol > li</entry> </row> <row> <entry>E + F</entry> <entry>an F element immediately preceded by sibling E</entry> <entry>li + li, div.head + div</entry> </row> <row> <entry>E ~ F</entry> <entry>an F element preceded by sibling E</entry> <entry>h1 ~ p</entry> </row> <row> <entry>E, F, G</entry> <entry>all matching elements E, F, or G</entry> <entry>a[href], div, h3</entry> </row> <row> <entry></entry> <entry></entry> <entry></entry> </row> <row> <entry namest="c1" nameend="c3" align='center' valign='bottom'><emphasis>Pseudo selectors</emphasis></entry> </row> <row> <entry>:lt(n)</entry> <entry>elements whose sibling index is less than n</entry> <entry>td:lt(3) finds the first 2 cells of each row</entry> </row> <row> <entry>:gt(n)</entry> <entry>elements whose sibling index is greater than n</entry> <entry>td:gt(1) finds cells after skipping the first two</entry> </row> <row> <entry>:eq(n)</entry> <entry>elements whose sibling index is equal to n</entry> <entry>td:eq(0) finds the first cell of each row</entry> </row> <row> <entry>:has(selector)</entry> <entry>elements that contains at least one element matching the selector</entry> <entry>div:has(p) finds divs that contain p elements</entry> </row> <row> <entry>:not(selector)</entry> <entry>elements that do not match the selector. See also Elements.not(String)</entry> <entry> <para>div:not(.logo) finds all divs that do not have the "logo" class.</para> <para>div:not(:has(div)) finds divs that do not contain divs.</para> </entry> </row> <row> <entry>:contains(text)</entry> <entry>elements that contains the specified text. The search is case insensitive. The text may appear in the found element, or any of its descendants.</entry> <entry>p:contains(jsoup) finds p elements containing the text "jsoup".</entry> </row> <row> <entry>:matches(regex)</entry> <entry>elements whose text matches the specified regular expression. The text may appear in the found element, or any of its descendants.</entry> <entry>td:matches(\\d+) finds table cells containing digits. div:matches((?i)login) finds divs containing the text, case insensitively.</entry> </row> <row> <entry>:containsOwn(text)</entry> <entry>elements that directly contains the specified text. The search is case insensitive. The text must appear in the found element, not any of its descendants.</entry> <entry>p:containsOwn(jsoup) finds p elements with own text "jsoup".</entry> </row> <row> <entry>:matchesOwn(regex)</entry> <entry>elements whose own text matches the specified regular expression. The text must appear in the found element, not any of its descendants.</entry> <entry>td:matchesOwn(\\d+) finds table cells directly containing digits. div:matchesOwn((?i)login) finds divs containing the text, case insensitively.</entry> </row> <row> <entry></entry> <entry>The above may be combined in any order and with other selectors</entry> <entry>.light:contains(name):eq(0)</entry> </row> <row> <entry></entry> <entry></entry> <entry></entry> </row> <row> <entry namest="c1" nameend="c3" align='center' valign='bottom'><emphasis>Structural pseudo selectors</emphasis></entry> </row> <row> <entry>:root</entry> <entry>The element that is the root of the document. In HTML, this is the html element. In a snippet method, this is the element where the current snippet method is declared. In a recursive Renderer, this is the target element which the current renderer is applied to.</entry> <entry>:root</entry> </row> <row> <entry>:nth-child(an+b)</entry> <entry>elements that have an+b-1 siblings before it in the document tree, for any positive integer or zero value of n, and has a parent element. For values of a and b greater than zero, this effectively divides the element's children into groups of a elements (the last group taking the remainder), and selecting the bth element of each group. For example, this allows the selectors to address every other row in a table, and could be used to alternate the color of paragraph text in a cycle of four. The a and b values must be integers (positive, negative, or zero). The index of the first child of an element is 1. In addition to this, :nth-child() can take odd and even as arguments instead. odd has the same signification as 2n+1, and even has the same signification as 2n.</entry> <entry>tr:nth-child(2n+1) finds every odd row of a table. :nth-child(10n-1) the 9th, 19th, 29th, etc, element. li:nth-child(5) the 5h li</entry> </row> <row> <entry>:nth-last-child(an+b)</entry> <entry>elements that have an+b-1 siblings after it in the document tree. Otherwise like :nth-child()</entry> <entry>tr:nth-last-child(-n+2) the last two rows of a table</entry> </row> <row> <entry>:nth-of-type(an+b)</entry> <entry>pseudo-class notation represents an element that has an+b-1 siblings with the same expanded element name before it in the document tree, for any zero or positive integer value of n, and has a parent element</entry> <entry>img:nth-of-type(2n+1)</entry> </row> <row> <entry>:nth-last-of-type(an+b)</entry> <entry>pseudo-class notation represents an element that has an+b-1 siblings with the same expanded element name after it in the document tree, for any zero or positive integer value of n, and has a parent element</entry> <entry>img:nth-last-of-type(2n+1)</entry> </row> <row> <entry>:first-child</entry> <entry>elements that are the first child of some other element.</entry> <entry>div > p:first-child</entry> </row> <row> <entry>:last-child</entry> <entry>elements that are the last child of some other element.</entry> <entry>ol > li:last-child</entry> </row> <row> <entry>:first-of-type</entry> <entry>elements that are the first sibling of its type in the list of children of its parent element</entry> <entry>dl dt:first-of-type</entry> </row> <row> <entry>:last-of-type</entry> <entry>elements that are the last sibling of its type in the list of children of its parent element</entry> <entry>tr > td:last-of-type</entry> </row> <row> <entry>:only-child</entry> <entry>elements that have a parent element and whose parent element hasve no other element children</entry> <entry></entry> </row> <row> <entry>:only-of-type</entry> <entry>an element that has a parent element and whose parent element has no other element children with the same expanded element name</entry> <entry></entry> </row> <row> <entry>:empty</entry> <entry>elements that have no children at all</entry> <entry></entry> </row> <row> <entry></entry> <entry></entry> <entry></entry> </row> </tbody> </tgroup> </table> <remark>Note: Because of the internal implementation of how to perform Renderer on target element, there may be unexpected temporary elements to be added into the Current DOM tree, which will be removed safely at the final stage of page production but may cause the structural pseudo selectors work incorrectly (However, the :root selector can still work well). </remark> </sect2> <sect2> <title>Render text</title> <para>add(String selector, String value) can be used to render a text under the element specified by given selector. All child nodes of the target element specified by selector will be emptied and the given String value will be rendered as a single text node of the target element.</para> <example> <programlisting language="java"> <![CDATA[ renderer.add("#someId", "xyz"); ]]> </programlisting> </example> <para>Long/long, Integer/int, Boolean/boolean will be treated as text rendering too.</para> <example> <programlisting language="java"> <![CDATA[ renderer.add("#someIdForLong", 123L); renderer.add("#someIdForInt", 123); renderer.add("#someIdForBool", true); ]]> </programlisting> </example> </sect2> <sect2> <title>Render DOM attribution</title> <para>add(String selector, String attr, String value) can be used to render attribute value of a DOM element. There are some rules will be applied for the pattern of specified "attr" and "value":</para> <itemizedlist> <listitem> <para>add("+class", value)</para> <para>call addClass(value) on target Element, null value will be treated as "null".</para> </listitem> <listitem> <para>add("-class", value)</para> <para>call removeClass(value) on target Element, null value will be treated as "null".</para> </listitem> <listitem> <para>add("class", value)</para> <para>call attr("class", value) on target Element if value is not null, for a null value, removeAttr("class") will be called.</para> </listitem> <listitem> <para>add("anyattr", value)</para> <para>call attr("anyattr", value) on target Element if value is not null, for a null value, removeAttr("anyattr") will be called.</para> </listitem> <listitem> <para>add("anyattr", SpecialRenderer.Clear)</para> <para>call removeAttr("anyattr") on target Element.</para> </listitem> <listitem> <para>add("+anyattr", value)</para> <para>call attr("anyattr", value) on target Element if value is not null, for a null value, removeAttr("anyattr") will be called.</para> </listitem> <listitem> <para>add("+anyattr", SpecialRenderer.Clear)</para> <para>call removeAttr("anyattr") on target Element.</para> </listitem> <listitem> <para>add("-anyattr", value)</para> <para>call removeAttr("anyattr") on target Element.</para> </listitem> </itemizedlist> <para>There is also an add method for attribution rendering that accepts arbitrary data as Object type: add(String selector, String attr, Object value). When the "value" is specified as a non-string value and the "attr" is specified as "+class" or "-class", A IllegalArgumentException will be thrown. When an arbitrary Object value is rendered to attribute by such method, an internal object reference id will be rendered to the target attribute instead of the original object since it cannot be treated as attribute string value directly. The object reference id can be used by variable injection for the nested snippet rendering. See the following example, we pass a Date instance to the nested snippet method: </para> <example> <programlisting language="xml"> <![CDATA[ <div afd:render="MySnippet:outer"> <div id="inner" afd:render="MySnippet:inner"> <span id="current-date"></span> </div> </div> ]]> </programlisting> <programlisting language="java"> <![CDATA[ public class MySnippet{ public Renderer outer(){ return Renderer.create("#innder", "now", new Date()); } public Renderer inner(Date now){ return Renderer.create("#current-date", now); } } ]]> </programlisting> </example> <para>This mechanism can be used for parametrized embedding too. Parameters can be specified by attribution rendering in the snippet method of parent template file and can be retrieved by the snippet method of child template file as same as the above example. </para> <example> <programlisting language="xml"> <![CDATA[ <!-- parent template --> <div afd:render="MySnippet:outer"> <afd:embed id="inner" target="child.html"></afd:embed> </div> ]]> </programlisting> <programlisting language="xml"> <![CDATA[ <!-- child template --> <div afd:render="MySnippet:embed"> <span id="current-date"></span> </div> ]]> </programlisting> <programlisting language="java"> <![CDATA[ public class MySnippet{ public Renderer outer(){ return Renderer.create("#innder", "now", new Date()); } public Renderer embed(Date now){ return Renderer.create("#current-date", now); } } ]]> </programlisting> </example> </sect2> <sect2> <title>Clear an Element</title> <para>On all the rendering methods, if the specified value is null, the target element will be removed. And there is also an enumeration value of SpecialRenderer.Clear which can be used to declare a remove operation for an element too.</para> <example> <programlisting language="java"> <![CDATA[ //if the String value is null, the target element will be removed String txt = null; Renderer.create("#someId", txt); ]]> </programlisting> <programlisting language="java"> <![CDATA[ import static com.astamuse.asta4d.render.SpecialRenderer.Clear Renderer.create("#someId", Clear); ]]> </programlisting> </example> <remark>Note that on the attribute rendering methods, if null value or SpecialRenderer.Clear are specified, as we mentioned in the previous section, the target attribute will be removed and the target element will remain.</remark> </sect2> <sect2> <title>Render raw Element</title> <para>An existing DOM element can be replaced by a new element by specifying the new element as the rendering value. The new element can be generated by DOM APIs or simply parsed from raw html source.</para> <example> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create(); Element ul = new Element(Tag.valueOf("ul"), ""); List<Node> lis = new ArrayList<>(); ul.appendChild(new Element(Tag.valueOf("li"), "").appendText("This text is created by snippet.(1)")); ul.appendChild(new Element(Tag.valueOf("li"), "").appendText("This text is created by snippet.(2)")); ul.appendChild(new Element(Tag.valueOf("li"), "").appendText("This text is created by snippet.(3)")); renderer.add("#someId", ul); String html = "<a href=\"https://github.com/astamuse/asta4d\">asta4d hp</a>"; renderer.add("#hp-link", ElementUtil.parseAsSingle(html)); ]]> </programlisting> </example> <para>There are several utility methods in ElementUtil that can help you operate DOM easier.</para> <remark>ElementUtil#parseAsSingle would cause potential cross-site issues, so take care of it and make sure that you have escaped all the raw html source correctly. Since Asta4D has provided plenty of rendering methods, you should try your best to avoid create element from raw html source. If you have to do something on raw element level, your first option should be DOM APIs and parsing raw html source should be your last alternative.</remark> </sect2> <sect2> <title>Arbitrary rendering for an Element</title> <para>Sometimes you will want to access the rendering target on raw element level and Asta4D allow you access the rendering target element by the interface of ElementSetter. ElementSetter asks the implementation of a callback method "set(Element elem)". As a matter of fact, the text rendering and attribute rendering are achieved by built-in implementation of ElementSetter(TextSetter and AttributeSetter).There is also another built-in ElementSetter implementation called ChildReplacer which can replace the children of rendering target by given element.</para> <example><title>source of ChildReplacer</title> <programlisting language="java"> <![CDATA[ public class ChildReplacer implements ElementSetter { private Element newChild; /** * Constructor * * @param newChild * the new child node */ public ChildReplacer(Element newChild) { this.newChild = newChild; } @Override public void set(Element elem) { elem.empty(); elem.appendChild(newChild); } } ]]> </programlisting> </example> <para>You can regard the built-in TextSetter, AttributeSetter and ChildReplacer as reference implementation in case of you need implement your own ElementSetter. Following example shows how to use ChildReplacer or declare an anonymous class for ElementSetter on rendering.</para> <example> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create(); renderer.add("#someId", new ChildReplacer(ElementUtil.parseAsSingle("<div>aaa</div>"))); renderer.add("#someNode", new ElementSetter(){ public void set(Element elem) { if(elem.tagName().equals("div")){ elem.addClass("someClass); } } }); ]]> </programlisting> </example> <remark>On element level, you can also parse element by Element#html(String html) method which will also cause potential cross-site issues. As same as the raw element rendering, parsing raw html source should be your last alternative.</remark> </sect2> <sect2> <title>Recursive rendering</title> <para>For a snippet method, the returned Renderer will be applied to the target element which declares the current snippet method. In the returned Renderer chain, you can also specify recursive Renderer which is only applied to the element specified by given CSS selector.</para> <example> <programlisting language="java"> <![CDATA[ Renderer.create("#someId", Renderer.create("a", "href", "https://github.com/astamuse/asta4d")); ]]> </programlisting> </example> </sect2> <sect2> <title>Debug renderer</title> <para>Because the Renderer is applied after your snippet method finished, it is difficult to debug if there is something wrong. Asta4D affords rendering debug function too. There are two overloaded debug method, one accepts a log message only and another accepts a log message and a selector. The debug renderer will output the current status of rendering target element to log file, if the selector is not specified, the whole rendering target of current snippet method will be output, if the selector is specified, only the matched child elements will be output. Log level can be configured by "com.astamuse.asta4d.render.DebugRenderer".</para> <example> <programlisting language="java"> <![CDATA[ //the whole target rendering target will be output before and after renderer.addDebugger("before render value"); renderer.add("#someId", value); renderer.addDebugger("after render value"); //only the a tag element will be output before and after renderer.addDebugger("before render value for link", "a"); renderer.add("a", "href", url); renderer.addDebugger("after render value for link", "a"); ]]> </programlisting> <remark>If you specified a selector on debugger but do not get any output, it usually means you specified wrong selector or the target element has been removed by previous rendering or outer snippet rendering.</remark> </example> </sect2> <sect2> <title>Missing selector warning</title> <para>If your specified selector on rendering method cannot match any element, Asta4D will output a warning message to log as <remark>"There is no element found for selector [#someId] at [ com.astamuse.asta4d.test.render.RenderingTest$TestRender.classAttrSetting(RenderingTest.java:73) ], if it is deserved, try Renderer#disableMissingSelectorWarning() to disable this message and Renderer#enableMissingSelectorWarning could enable this warning again in your renderer chain"</remark>.</para> <para>Note that the place where the missing selector declared is output to log too, which is disabled by default since it is expensive on production environment. You can enable the source row number output by Configuration#setSaveCallstackInfoOnRendererCreation.</para> <para>Sometimes, the missing selector may be designed by your logic, you can disable the warning message on your rendering chain temporarily as following:</para> <example> <programlisting language="java"> <![CDATA[ renderer.disableMissingSelectorWarning(); renderer.add("#notExistsId", "abc"); renderer.enableMissingSelectorWarning(); ]]> </programlisting> </example> </sect2> <sect2> <title>List rendering</title> <para>Asta4D does not only allow you to rendering single value to an element, but also allow you to duplicate elements by list data, which is usually used to perform list rendering. java.lang.Iterable of String/Integer/Long/Boolean can be rendered directly as text rendering:</para> <example> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create(); renderer.add("#strList", Arrays.asList("a", "b", "c")); renderer.add("#intList", Arrays.asList(1, 2, 3)); renderer.add("#longList", Arrays.asList(1L, 2L, 3L)); renderer.add("#boolList", Arrays.asList(true, false, true)); ]]> </programlisting> </example> <para>On list rendering, the matched element will be duplicated times as the size of the list and the value will be rendered to each duplicated element. You can also perform complex rendering for arbitrary list data by RowConvertor:</para> <example> <programlisting language="java"> <![CDATA[ render.add("#someIdForRenderer", Arrays.asList(123, 456, 789), new RowConvertor<Integer, Renderer>() { @Override public Renderer convert(int rowIndex, Integer obj) { return Renderer.create("#id", "id-" + obj).add("#otherId", "otherId-" + obj); } }); ]]> </programlisting> </example> <para>Since we will return Renderer in most cases, the RowConvertor can be replaced by RowRenderer which can omit the type declaration of Renderer:</para> <example> <programlisting language="java"> <![CDATA[ render.add("#someIdForRenderer", Arrays.asList(123, 456, 789), new RowRenderer<Integer>() { @Override public Renderer convert(int rowIndex, Integer obj) { return Renderer.create("#id", "id-" + obj).add("#otherId", "otherId-" + obj); } }); ]]> </programlisting> </example> <para>The returned Renderer by RowConvertor/RowRenderer will be applied to each duplicated element by the given list data.</para> <para>On list rendering, the rendering method accepts java.lang.Iterable rather than java.util.List, which afford more flexibilities to developers. Note that if the given iterable is empty, the target element will be duplicated 0 times, which means the target element will be removed.</para> <para>Asta4D also afford parallel list rendering for you, simply use ParallelRowConvertor/ParallelRowRenderer instead of RowConvertor/RowRenderer:</para> <example> <programlisting language="java"> <![CDATA[ render.add("#someIdForRenderer", Arrays.asList(123, 456, 789), new ParallelRowRenderer<Integer>() { @Override public Renderer convert(int rowIndex, Integer obj) { return Renderer.create("#id", "id-" + obj).add("#otherId", "otherId-" + obj); } }); ]]> </programlisting> </example> <para>The parallel list rendering ability is provided by an utility class called ListConvertUtil which basically provides various transform methods for list data conversion like the map function in Scala/Java8. <remark>For Java8, lambda and stream api support will be added in future.</remark></para> <para>The ListConvertUtil uses a thread pool to perform parallel transforming, the size of pool can be configured by Configuration#listExecutorFactory#setPoolSize. There is also an import configuration of ParallelRecursivePolicy. When perform the parallel list transforming recursively, thread dead lock would potentially occur, so you have to choose a policy to handle this case:</para> <itemizedlist> <listitem> <para>EXCEPTION</para> <para>When recursive parallel list transforming is identified, throw an RuntimeException.</para> </listitem> <listitem> <para>CURRENT_THREAD</para> <para>When recursive parallel list transforming is identified, the child transforming will be performed in the same thread of parent transforming without picking up an usable thread from pool.</para> </listitem> <listitem> <para>NEW_THREAD</para> <para>When recursive parallel list transforming is identified, the child transforming will be performed in a newly generated thread out of the configured thread pool, the generated thread will be finished immediately after the child transforming finished.</para> </listitem> </itemizedlist> <para>We recommend EXCEPTION or CURRENT_THREAD and the default is EXCEPTION.</para> </sect2> </sect1> <sect1> <title>Other things about snippet and rendering</title> <sect2> <title>Nested snippet</title> <para>Snippet can be declared recursively.There is a convention that the outer snippet will always be executed on a prior order.</para> <example> <programlisting language="xml"> <![CDATA[ <div afd:render="OuterSnippet"> <div id="inner" afd:render="InnerSnippet"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </div> </div> ]]> </programlisting> </example> <para>In the above example, the "InnerSnippet" will be executed after the "OuterSnippet" has been executed, which also means you can configure the inner snippet dynamically.</para> <example> <programlisting language="java"> <![CDATA[ public class OuterSnippet{ public Renderer render(){ return Renderer.create("#inner", "hasprofile", "true"); } } public class InnerSnippet{ public Renderer render(bool hasprofile){ if(hasprofile){ return Renderer.create("#name span", "Bob").add("#age span", 27); }else{ return Renderer.create("*", Clear); } } } ]]> </programlisting> </example> </sect2> <sect2> <title>InitializableSnippet</title> <para>The snippet class instance is singleton in request scope and will be created at the first time a snippet is required. After the snippet class instance has been created, field value injection will be applied to the created instance once(About detail of value injection, see the later chapter). After all the field has been injected, the framework will check whether the current class implements the "InitializableSnippet" interface, if true, the init method of InitializableSnippet will be invoked once.</para> <example> <programlisting language="java"> <![CDATA[ public static class InitSnippet implements InitializableSnippet { @ContextData private String value; private String resolvedValue; @Override public void init() throws SnippetInvokeException { resolvedValue = value + "-resolved"; } } ]]> </programlisting> </example> <para>In the above example, the field "value" will be injected after the instance is created, then the init method will be applied to finish the complete initialization logic of the snippet class.</para> </sect2> <sect2> <title>Component rendering</title> <para>For the view first policy, we will treat the template files as first class things. The embed file mechanism allow you separate some view blocks as independent components at template file layer. There is also a snippet class level mechanism that afford you the same ability as embed file, which is called "Component".</para> <para>Why we need "Component"? The embed file can only be include statically, but the "Component" is an extendible Java class which can be configured by arbitrary Java code and polymorphism can be easily performed too. Basically, The "Component" mechanism can help developer to build independent view component easier than static embed file.</para> <para>The constructor of Component accepts a string value as an embed file path or an instance of Element, and also an optional AttributesRequire can be specified to provide some initialization parameters as same as the parametrized embedding introduced in the previous section.</para> <example><title>constructors of Component</title> <programlisting language="java"> <![CDATA[ public Component(Element elem, AttributesRequire attrs) throws Exception { ... } public Component(Element elem) throws Exception { ... } public Component(String path, AttributesRequire attrs) throws Exception { ... } public Component(String path) throws Exception { ... } ]]> </programlisting> </example> <example><title>render a component</title> <programlisting language="java"> <![CDATA[ public Renderer render(final String ctype) throws Exception { return Renderer.create("span", new Component("/ComponentRenderingTest_component.html", new AttributesRequire() { @Override protected void prepareAttributes() { this.add("value", ctype); } })); } ]]> </programlisting> <para>In this example, the target element specified by the selector "span" will be completely replaced by the result of Component#toElement().</para> </example> <para>Commonly, we do not render a component as above example, we usually extend from Component and expose a constructor with business initialization parameters or supply a group of business initialization methods, by which we can build an independent view component simply.</para> <para>Further, Component also has a "toHtml" method which will return the html source of the component rendering result. This method can be used by ajax request to acquire a dynamically rendered component.</para> </sect2> <sect2> <title>SnippetInterceptor</title> </sect2> <sect2> <title>SnippetExtractor</title> </sect2> <sect2> <title>SnippetResolver</title> </sect2> <sect2> <title>SnippetInvoker</title> </sect2> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-2,653,215,763,664,278,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-form-flow" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>details of form flow</title> <remark>To be written.</remark> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
1,244,035,855,570,994,200
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-i18n" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>i18n</title> <sect1 id="i18n-message"> <title>message stringization</title> <para>Asta4D affords basic i18n support by a built-in I18nMessageHelper. I18nMessageHelper requires a MessagePatternRetriever implementation to retrieve message by key. There is also a default implementation JDKResourceBundleMessagePatternRetriever which uses the JDK's built-in resource bundle mechanism. </para> <sect2 id="i18n-I18nMessageHelper"> <title>I18nMessageHelper</title> <para>I18nMessageHelper is an abstract classes which affords the basic interface for handling messages:</para> <itemizedlist> <listitem> <para>getMessage(String key)</para> <sbr/> </listitem> <listitem> <para>getMessage(Locale locale, String key);</para> <sbr/> </listitem> <listitem> <para>getMessageWithDefault(String key, Object defaultPattern)</para> <para>return defaultPattern#toString() if message not found</para> <sbr/> </listitem> <listitem> <para>getMessageWithDefault(Locale locale, String key, Object defaultPattern)</para> <para>return defaultPattern#toString() if message not found</para> <sbr/> </listitem> </itemizedlist> <para>There are also two extended classes from I18nMessageHelper, which afford more flexible message functionalities especially about formatting message by given parameters. Configuration#setI18nMessageHelper can be used to customized which helper you want to use. The default is OrderedParamI18nMessageHelper. (<remark>I18nMessageHelperTypeAssistant#getConfiguredMappedHelper and I18nMessageHelperTypeAssistant#getConfiguredOrderedHelper can be used to retrieve a type safe configured helper.</remark>) </para> <itemizedlist> <listitem> <para>MappedParamI18nMessageHelper</para> <para>Allow format message by a given parameter map, A MappedValueFormatter is required to supply concrete formatting style and the default is ApacheStrSubstitutorFormatter which uses StrSubstitutor from Apache Common lang3.</para> <sbr/> </listitem> <listitem> <para>OrderedParamI18nMessageHelper(default)</para> <para> Allow format message by a given parameter array. A OrderedValueFormatter is required to supply concrete formatting style and the default is JDKMessageFormatFormatter which uses JDK's MessageFormat to format message string.</para> <sbr/> </listitem> </itemizedlist> <para>There are several value formatter can be used by the above helpers. Notice that The MappedParamI18nMessageHelper requires implementation of MappedValueFormatter and the OrderedParamI18nMessageHelper requires implementation of OrderedValueFormatter. </para> <table frame='all'><title>Built-in value formatters</title> <tgroup cols='4' align='left' colsep='1' rowsep='1'> <colspec colname='c1'/> <colspec colname='c2'/> <colspec colname='c3'/> <colspec colname='c4'/> <thead> <row> <entry>formatter</entry> <entry>interface</entry> <entry>Description</entry> <entry>Example</entry> </row> </thead> <tbody> <row> <entry>ApacheStrSubstitutorFormatter(default)</entry> <entry>MappedValueFormatter</entry> <entry>Use Apache Commons Lang's <ulink url="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/text/StrSubstitutor.html#replace(java.lang.CharSequence)"> StrSubstitutor#replace</ulink> to format messages. Use "{" and "}" to represent variables place holder.</entry> <entry>"There are {count} items in the {item-name} list."</entry> </row> <row> <entry>JDKMessageFormatFormatter(default)</entry> <entry>OrderedValueFormatter</entry> <entry>Use JDK's <ulink url="http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html#format(java.lang.String, java.lang.Object...)"> MessageFormat#format</ulink> to format messages.</entry> <entry>"There are {1} items in the {2} list."</entry> </row> <row> <entry>SymbolPlaceholderFormatter</entry> <entry>OrderedValueFormatter</entry> <entry>Use JDK's <ulink url="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)"> String#format</ulink> to format messages.</entry> <entry>"There are %d items in the %s list."</entry> </row> </tbody> </tgroup> </table> </sect2> <sect2 id="i18n-MessagePatternRetriever"> <title>MessagePatternRetriever</title> <para>The I18nMessageHelper requires a MessagePatternRetriever implementation to retrieve message by key. There is a default implementation JDKResourceBundleMessagePatternRetriever which uses the JDK's built-in resource bundle mechanism. The base name of resource bundle files can be specified by JDKResourceBundleMessagePatternRetriever#setResourceNames which accepts a list of base name. The configured resource bundles will be passed to JDK's <ulink url="http://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)"> ResourceBundle#getBundle(String baseName, Locale locale, ClassLoader loader)</ulink> to retrieve messages. </para> <para>As the implementation of JDKResourceBundleMessagePatternRetriever, if the given locale is null, the default locale decision mechanism will be performed. See <xref linkend="i18n-default-locale-decision"/>.</para> <para>Further, the JDKResourceBundleMessagePatternRetriever accepts ResourceBundleFactory to allow customize how to retrieve a resource bundle. The default is CharsetResourceBundleFactory which allows specify the encoding of message bundle files. Another built-in implementation is the LatinEscapingResourceBundleFactory, as the name suggests, the message files must be escaped by JDK's standard mechanism(via native2ascii). </para> </sect2> <sect2 id="i18n-default-locale-decision"> <title>Default locale</title> <para>The default locale will be decided by the following order and stop at the first non-null returned value.</para> <orderedlist> <listitem> <para>Context.getCurrentThreadContext().getCurrentLocale()</para> </listitem> <listitem> <para>Locale.getDefault()</para> </listitem> <listitem> <para>Locale.ROOT</para> </listitem> </orderedlist> <remark>Since the Locale.getDefault() will return the local machine's locale by default, you may need to override the default locale to ROOT at the staring of your web application.</remark> </sect2> <sect2 id="i18n-afd-msg"> <title>afd:msg</title> <para>"afd:msg" tag can be used to declare an i18n aware message in a template file. The basic usage is as following:</para> <programlisting language="xml"> <![CDATA[ <section> <article> <div class="panel panel-default"><div class="panel-body"> <!-- the inner html will be treated as default message if the key is not found in message bundle --> <afd:msg id="notexistingkey" key="sample.notexistingkey" p0="parameter works as well.">text here to be treated as default message.{0}</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- simply specify parameters on tag --> <afd:msg id="peoplecount" key="sample.peoplecount" p0="4">dummy text</afd:msg><br/> <afd:msg id="peoplecount" key="sample.peoplecount" p0="7" locale="ja_JP">dummy text</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- the parameter can be rendered by snippet too --> <afd:snippet render="ComplicatedSnippet:setMsgParam"> <afd:msg id="peoplecount" key="sample.peoplecount" p0="4">dummy text</afd:msg><br/> <afd:msg id="peoplecount" key="sample.peoplecount" p0="7" locale="ja_JP">dummy text</afd:msg><br/> </afd:snippet> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- attribute started with "@" will be treated as a key --> <afd:msg id="weatherreport" key="sample.weatherreport" @p0="sample.weatherreport.sunny">天気</afd:msg><br/> <afd:msg id="weatherreport" key="sample.weatherreport" @p0="sample.weatherreport.sunny" locale="ja_JP">天気</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- attribute started with "#" will be treated as a sub key of current key, thus sample.weatherreport.sunny will be searched --> <afd:msg id="weatherreport" key="sample.weatherreport" #p0="rain">天気</afd:msg><br/> <afd:msg id="weatherreport" key="sample.weatherreport" #p0="rain" locale="ja_JP">天気</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- treat message as text --> <afd:msg key="sample.textUrl"></afd:msg><br/> <!-- treat message as html --> <afd:msg key="sample.htmlUrl"></afd:msg><br/> <!-- treat message as text even it begins with html: --> <afd:msg key="sample.escapedUrl"></afd:msg><br/> </div></div> </article> </section> ]]> </programlisting> <programlisting language="java"> <![CDATA[ public Renderer setMsgParam() { Renderer render = Renderer.create(); render.add("#peoplecount", "p0", 15); return render; } ]]> </programlisting> <para>There are something need to be explained:</para> <itemizedlist> <listitem> <para>default message</para> <para>As commented in the source, the inner content of "afd:msg" will be treated as default message in case of the message of specified key cannot be found. Note that the default message will be formatted by specified parameters too.</para> <para>This mechanism can also be used as a simple text replacing mechanism in the html template file in case of necessity.</para> <sbr/> </listitem> <listitem> <para>parameter name</para> <para>If the configured I18nMessageHelper is MappedParamI18nMessageHelper, the attribute names of current "afd:msg" element will be treated as parameter names directly. And if the configured I18nMessageHelper is OrderedParamI18nMessageHelper which is the default one, the attribute names started with single "p" and following with 0-started numbers will be treated as the values of parameter value array.</para> <sbr/> </listitem> <listitem> <para>recursive parameter</para> <para>The attributes which name started with "@" or "#" will be treated as recursive message's key. The different between "@" and "#" is that the "@" will be treated as a complete key but the "#" will be treated as a sub key of current message key.</para> <sbr/> </listitem> <listitem> <para>parameter value</para> <para>The value of attributes can be specified directly in the html template file, also can be rendered by a snippet as in the above example.</para> <sbr/> </listitem> <listitem> <para>locale</para> <para>Locale can be specified explicitly by ISO 639 locale string, if not, the default locale decision mechanism will be performed. See <xref linkend="i18n-default-locale-decision"/>.</para> <sbr/> </listitem> </itemizedlist> </sect2> </sect1> <sect1 id="i18n-file-search"> <title>file search order</title> <para>The built-in template resolver and static resource handler can match the target file name with awareness of locale. The match locale will be decided by the default locale decision mechanism(See <xref linkend="i18n-default-locale-decision"/>). After the locale is decided, for example, for a locale as Locale("fr", "CA", "UNIX") to search a html template file "index.html", the target file will be searched by following order:</para> <orderedlist> <listitem> <para>index_fr_CA_UNIX.html</para> </listitem> <listitem> <para>index_fr_CA.html</para> </listitem> <listitem> <para>index_fr.html</para> </listitem> <listitem> <para>index.html</para> </listitem> </orderedlist> <para>For the static resource files such as js, css, jpg, etc. will be searched by the same order as well.</para> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,437,159,825,845,869,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-overview" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Overview</title> <section> <title>Why Asta4D</title> <para>In the past decade, plenty of Java based web application frameworks are generated. Especially the MVC architecture and JSP tag libs (or other traditional template technologies) that has greatly released our productivity. But unfortunately, we are still suffering from the following situations: </para> <itemizedlist> <listitem> <para>The designers or front-end engineers are keeping complaining the mixed-in dynamic code, as they disturb their efforts of redesigning the page style or structure. And in the mean time, the back-end developers are also complaining that the front-end guys break the working page frequently, because redesign or the new design is hard to merge due to the huge cost of source refactorying. </para> <sbr/> </listitem> <listitem> <para>The developers are complaining about the poor functionalities of template language which they are using and tired from the various magic skills for complex rendering logic.</para> <sbr/> </listitem> <listitem> <para>The developers are discontented with the counterproductivity of traditional MVC architecture and desire a more efficient approach.</para> <sbr/> </listitem> </itemizedlist> </section> <section> <title>How Asta4D helps us</title> <para>Asta4D is our solution to combat those issues. Thanks to lift, from where we learn a lot. We designed Asta4D complying with the following points: </para> <itemizedlist> <listitem> <para>Separate template and rendering logic</para> <para>Asta4D affords front-end engineers a friendly environment by separating rendering logic from template files which are pure html files. At the mean time, back-end engineers can use the powerful Java language to implement the rendering logic without being suffering from the "poor and sometimes magic" template languages. </para> <sbr/> </listitem> <listitem> <para>Testable rendering logic</para> <para>All of the rendering logic in Asta4D is testable and developers can simply test them by writing simple junit cases, which could replace over than half of selenium tests</para> <sbr/> </listitem> <listitem> <para>High security of being immune from cross-site(XSS/CSRF)</para> <para>Asta4D is, by nature, immune from cross-site(XSS/CSRF) problems. You do not need to take care of cross-site any more. All the rendered value would be escaped by default and your clients have no chance to put malicious contents to your server. </para> <sbr/> </listitem> <listitem> <para>View first</para> <para>Asta4D also affords higher productivity than traditional MVC architecture by View First mechanism. And it is also easier to change than traditional MVC architecture. </para> <sbr/> </listitem> <listitem> <para>Isolate side effect with request handler</para> <para>Asta4D imports the conception of "side-effect" from functional programming languages and separating the "side-effect" by request handlers, which afford more flexibility on page rendering because the view layer is side-effect free now. Therefore Asta4D allows parallel page rendering in multiple threads as a built-in feature. </para> <sbr/> </listitem> <listitem> <para>Advanced MVC</para> <para>Asta4D affords developers a evolved MVC architecture which is more clarified for the duty of each application layer than the traditional MVC architecture. </para> <sbr/> </listitem> </itemizedlist> </section> <section> <title>What does the name of "Asta4D" mean</title> <para>The name of Asta4D is from our company's name: astamuse. We explain the "4D" as following ways:</para> <itemizedlist> <listitem> <para>For Designer</para> <para>Asta4D consider the design friendliness as the most important factor of itself. We hope web designers can fulfil their maximum potential of creativity without squandering their time on the back-end technologies which they could never be adept at. </para> <sbr/> </listitem> <listitem> <para>For developer</para> <para>We hope Asta4D can help developers to achieve their work more easily. Developers would never be afflicted with complex rendering logic because they can use powerful Java language to do whatever they want since the rendering has been split from template files. View first also releases developers from the cumbersome MVC architecture, now they have more time to have a cup of coffee.</para> <sbr/> </listitem> <listitem> <para>4 Dimension</para> <para>We believe that Asta4D can act as a wormhole that connects the front-end and the back-end. We can move quicker by Asta4D just like we are going through the 4 dimensional space. </para> <sbr/> </listitem> </itemizedlist> </section> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
7,405,007,597,738,985,000
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter [ <!ENTITY % docvar SYSTEM "../META/var.ent" > %docvar; ]> <chapter xml:id="overview" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Asta4dServlet and configuration</title> <sect1> <title>Asta4dServlet</title> <para>All the http requests are handled by Asta4dServlet which allows developers to override several methods to customize its actions. The web.xml would be like following:</para> <example> <programlisting language="xml"> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- standalone without spring --> <servlet> <servlet-name>Asta4D Servlet</servlet-name> <servlet-class>com.astamuse.asta4d.web.servlet.Asta4dServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Asta4D Servlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> ]]> </programlisting> </example> <para>The following methods can be overridden:</para> <itemizedlist> <listitem> <para>createConfiguration()</para> <para>Overriding this methods allows developers to configure the framework by code. </para> <example> <programlisting language="java"> <![CDATA[ @Override protected WebApplicationConfiguration createConfiguration() { WebApplicationConfiguration conf = super.createConfiguration(); conf.setSnippetResolver(new DefaultSnippetResolver() { @Override protected Object createInstance(String snippetName) throws SnippetNotResovlableException { return super.createInstance("com.astamuse.asta4d.sample.snippet." + snippetName); } }); conf.setUrlMappingRuleInitializer(new UrlRules()); conf.getPageInterceptorList().add(new SamplePageInterceptor()); return conf; } ]]> </programlisting> </example> </listitem> <listitem> <para>service()</para> <para>Developers can intercept the http request by overriding this method. The following example shows how to rewrite the access url by adding pre request logic:</para> <example> <programlisting language="java"> <![CDATA[ @Override protected void service() throws Exception { WebApplicationContext context = Context.getCurrentThreadContext(); HttpServletRequest request = context.getRequest(); String requestURI = request.getRequestURI(); if (requestURI.startsWith("/abc/")) { context.setAccessURI(requestURI.substring(5)); } super.service(); } ]]> </programlisting> </example> <para>Request time measuring can be performed too:</para> <example> <programlisting language="java"> <![CDATA[ @Override protected void service() throws Exception { long startTime = System.currentTimeMillis(); try { super.service(); } finally { long endTime = System.currentTimeMillis(); System.out.println("request time:" + (endTime - startTime)); } } ]]> </programlisting> </example> </listitem> <listitem> <para>createAsta4dContext()</para> <para>Overriding this methods allows developers to afford customized Context implementation.</para> </listitem> <listitem> <para>createConfigurationInitializer()</para> <para>Overriding this methods allows developers to customize the configuration file initialization logic. See details at next section.</para> </listitem> </itemizedlist> </sect1> <sect1> <title>Configuration file</title> <para>In the previous section, we introduced that Asta4D can be configured by overriding createConfiguration() method and we also introduced a method called createConfigurationInitializer which allows customize the configuration file initialization logic. Asta4D allows to be configured by an extra configuration file which will be analyzed by the created configuration initializer. </para> <para>The default implementation of configuration initializer will seek the configuration file by following order:</para> <orderedlist> <listitem> <para>Calling retrievePossibleConfigurationFileNames(Overridable) to retrieve all possible configuration file names which could be an array of String. The default value is "asta4d.conf.properties" only.</para> </listitem> <listitem> <para>Search all the possible names in classpath by order. The first found one will be used.</para> </listitem> <listitem> <para>If there is no configuration file found in classpath, calling retrieveConfigurationFileNameKey(Overridable) to get a key. The default key is "asta4d.conf".</para> </listitem> <listitem> <para>Retrieve the value of key retrieve in previous step by the order as: ServletConfig, JDNI Context, System properties.</para> </listitem> <listitem> <para>If there is a value found in the previous step, open a file as configuration file by treating the found value as a file path.</para> </listitem> </orderedlist> <para>As mentioned above, the two methods of retrievePossibleConfigurationFileNames and retrieveConfigurationFileNameKey can be overridden to customize configuration file name and the file path can be also configured by the key "asta4d.conf" at servlet mapping configuration(ServletConfig), JDNI configuration(JDNI context) or command line parameter(System properties).</para> <para>Further, the default implementation does only support the format of configuration file as Java standard properties file. All the configured key/value will be treated as setXXX method calling on WebApplicationConfiguration instance. The key can be a dot split string which will be treated as recursive property accessing on WebApplicationConfiguration instance.</para> <example> <programlisting language="ini"> <![CDATA[ urlMappingRuleInitializer=com.astamuse.asta4d.sample.UrlRules cacheEnable=false snippetExecutorFactory.threadName=asta4d-sample-snippet snippetExecutorFactory.poolSize=100 listExecutorFactory.threadName=asta4d-sample-list listExecutorFactory.poolSize=100 ]]> </programlisting> </example> <para>The above configuration equals to the following source:</para> <example> <programlisting language="java"> <![CDATA[ WebApplicationConfiguration conf = super.createConfiguration(); conf.setUrlMappingRuleInitializer(new UrlRules()); conf.setCacheEnable(false); ((DefaultExecutorServiceFactory) conf.getSnippetExecutorFactory()).setThreadName("asta4d-sample-snippet"); ((DefaultExecutorServiceFactory) conf.getSnippetExecutorFactory()).setPoolSize(100); ((DefaultExecutorServiceFactory) conf.getListExecutorFactory()).setThreadName("asta4d-sample-list"); ((DefaultExecutorServiceFactory) conf.getListExecutorFactory()).setPoolSize(100); ]]> </programlisting> </example> <para>All the configurable items can be found at <ulink url="http://astamuse.github.io/asta4d/javadoc/&javadocversion;/com/astamuse/asta4d/web/WebApplicationConfiguration.html">JavaDoc</ulink>.</para> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,516,175,308,509,533,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-var-injection" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Variable injection</title> <sect1 id="vi-context"> <title>Context</title> <sect2> <title>Context/WebApplicationContext</title> <para>Asta4D use "Context" to manage data life cycle. The "Context" in asta4d-core supplies the basic data management mechanism and the WebApplicationContext from asta4d-web afford more powerful extending for web application development. Commonly, we will only use WebApplicationContext in our application. There are two ways to retrieve an instance of WebApplicationContext.</para> <example><title>Retrieve an instance of WebApplicationContext by static method</title> <programlisting language="java"> <![CDATA[ WebApplicationContext context = Context.getCurrentThreadContext(); ]]> </programlisting> </example> <example><title>Retrieve an instance of WebApplicationContext by injection</title> <programlisting language="java"> <![CDATA[ public class PageSnippet { public Renderer render(WebApplicationContext context) { ... } } ]]> </programlisting> </example> <para>As the name of "getCurrentThreadContext" suggested, the context is managed per thread, and also that the context will be initialized before every http request is processed and will be cleared after every http request process has finished.</para> <para>WebApplicationContext affords several methods to retrieving raw servlet apis and other helpful information:</para> <itemizedlist> <listitem> <para>getRequest</para> <para>Return the HttpServletRequest instance of current request.</para> </listitem> <listitem> <para>getResponse</para> <para>Return the HttpServletResponse instance of current request.</para> </listitem> <listitem> <para>getServletContext</para> <para>Return the ServletContext instance of current request.</para> </listitem> <listitem> <para>getAccessURI</para> <para>Return the rewritten url of current request. For details about URL rewritting, see later chapter.</para> </listitem> </itemizedlist> </sect2> <sect2 id="vi-scope"> <title>Scope</title> <para>The context provides a mechanism to manage data by scopes. There are only 3 scopes supplied by asta4d-core's Context, but the WebApplicationContext from asta4d-web supply more scopes to help web application development.</para> <variablelist> <title>Available scopes(with the constant name):</title> <varlistentry> <term>global(SCOPE_GLOBAL)</term> <listitem> <para>The data saved in global scope can be accessed cross all the contexts, you can treat it as a static object pool. </para> </listitem> </varlistentry> <varlistentry> <term>default(SCOPE_DEFAULT)</term> <listitem> <para>The data saved in default scope can only be access by the current context. </para> </listitem> </varlistentry> <varlistentry> <term>element attribute(SCOPE_ATTR)</term> <listitem> <para>This scope is related to snippet rendering. An element attribute scope is a wrapping of element attribute. When you try to retrieve data from element attribute scope, the attribute of current rendering target element will be checked and the corresponding attribute value will be returned, further, if there is no corresponding attribute in the current rendering target element's attributes, all the parents of current rendering target element will be checked recursively. </para> </listitem> </varlistentry> <varlistentry> <term>request(SCOPE_REQUEST)</term> <listitem> <para>The data saved in default scope can only be access in the current http request process. Note that the request scope is simply delegated to the default scope and it is different from servlet api's http request attribute. </para> </listitem> </varlistentry> <varlistentry> <term>path var(SCOPE_PATHVAR)</term> <listitem> <para>Path var scope represents the variables declared in url rules. </para> </listitem> </varlistentry> <varlistentry> <term>query parameter(SCOPE_QUERYPARAM)</term> <listitem> <para>Query parameter scope represents the query parameters specified at the part after question mark in an url.</para> </listitem> </varlistentry> <varlistentry> <term>session(SCOPE_SESSION)</term> <listitem> <para>Session scope represents the data saved in http session.</para> </listitem> </varlistentry> <varlistentry> <term>header(SCOPE_HEADER)</term> <listitem> <para>Session scope represents the header data from a http request.</para> </listitem> </varlistentry> <varlistentry> <term>cookie(SCOPE_COOKIE)</term> <listitem> <para>Cookie scope represents the cookie data from a http request.</para> </listitem> </varlistentry> <varlistentry> <term>flash(SCOPE_FLASH)</term> <listitem> <para>Asta4D affords a mechanism to allow pass data to the redirected http request, which is called flash data.</para> </listitem> </varlistentry> </variablelist> <para>Normally, the data saved in context can be accessed by variable injection. If you need get data manually, you can do it as following:</para> <example><title>Retrieve data from context</title> <programlisting language="java"> <![CDATA[ WebApplicationContext context = Context.getCurrentThreadContext(); //from default scope Integer count = context.get("saved-count"); //from session Integer sessionCount = context.get(WebApplicationContext.SCOPE_SESSION, "saved-count"); ]]> </programlisting> </example> <para>You can implement your own customized scope or afford you customized implementation for existing scopes. You need extend from WebApplicationContext then override the method called "createMapForScope".<remark>(If you only want to split your data from default scope, you can simply specify a new scope name and a new scope will be created automatically, the created scope's life cycle is as the same as default scope)</remark> </para> <example><title>Customized memcached drived session management</title> <programlisting language="java"> <![CDATA[ public class MyContext extends WebApplicationContext { @Override protected ContextMap createMapForScope(String scope) { ContextMap map = null; switch (scope) { case SCOPE_SESSION: { HttpServletRequest request = getRequest(); map = new MemcachedSessionMap(request); default: map = super.createMapForScope(scope); } return map; } } ]]> </programlisting> </example> <para>See later chapter of Asta4dServerlet for how to configure Asta4D to use the customized Context implementation instead of the default WebApplicationContext.</para> </sect2> <sect2 id="vi-ContextBindData"> <title>ContextBindData</title> <para>Since all the data query logic are performed at snippet class, we will want to avoid duplicated query on same page rendering. The recommended solution is caching your query result by cache library such as ehcache. But Asta4D also affords you an alternative solution for some simple cases, which is called ContextBindData.</para> <para>ContextBindData can be treated as a lazy load instance field for Java class. It is warranted that a ContextBindData will be initialized only once in a same Asta4D context and it will only be initialized when you first call it. There are some exceptions for the warranty about initializing only once, we will explain them later.</para> <example> <programlisting language="java"> <![CDATA[ public class PageSnippet { @ContextData private int count; private ContextBindData<Integer> data = new ContextBindData<Integer>(true) { @Override protected Integer buildData() { return count + 1; } }; public Renderer render() { return Renderer.create("*", data.get()); } } ]]> </programlisting> </example> <para>You should have noticed that we pass a "true" to the constructor of ContextBindData, which means we require the warranty that it should be only initialize once in the current context. If we pass nothing or pass a "false" to the constructor, the buildData method may be invoked multiple times in multi-thread rendering, but which is faster than warranted initialization simply because of skipping the multi-thread lock process.</para> <para>Again, we recommend to use cache library to avoid duplicated query, but you can use ContextBindData as a simple, light weight alternative. See detail of <xref linkend="best-snippet-way"/>.</para> </sect2> </sect1> <sect1 id="vi-injection"> <title>Injection</title> <sect2 id="vi-contextdata"> <title>@ContextData</title> <para>All fields annotated by @ContextData in a snippet class will be initialized/injected automatically when the snippet class instance is initialized. Further, even the method parameters of snippet rendering method and request handle method are automatically injected, you can still customize the injection by extra @ContextData annotation.</para> <para>Note that there are something different between field injection and method parameter injection. The fields of snippet class without @ContextData will not be injected, but method parameters will be always injected even without @ContextData.</para> <variablelist> <title>Available configurations of @ContextData:</title> <varlistentry> <term>name</term> <listitem> <para>The name of saved data in context. If it is not specified, the field name or parameter name will be used(This requires that you reverse the parameter names when compile). </para> </listitem> </varlistentry> <varlistentry> <term>scope</term> <listitem> <para>The scope of saved data in context. If it is no specified, Asta4D will try to search the data in all the scopes by a predefined order:</para> <orderedlist> <listitem> <para>element attribute(SCOPE_ATTR)</para> </listitem> <listitem> <para>path var(SCOPE_PATHVAR)</para> </listitem> <listitem> <para>query parameter(SCOPE_QUERYPARAM)</para> </listitem> <listitem> <para>flash(SCOPE_FLASH)</para> </listitem> <listitem> <para>cookie(SCOPE_COOKIE)</para> </listitem> <listitem> <para>hearder(SCOPE_HEADER)</para> </listitem> <listitem> <para>request/default(SCOPE_REQUEST/SCOPE_DEFAULT)</para> </listitem> <listitem> <para>session(SCOPE_SESSION)</para> </listitem> <listitem> <para>global(SCOPE_GLOBAL)</para> </listitem> </orderedlist> <para>This order can be configured via WebApplicationContextDataFinder#setDataSearchScopeOrder.See details at <xref linkend="vi-ContextDataFinder"/></para> </listitem> </varlistentry> <varlistentry> <term>typeUnMatch</term> <listitem> <para>The policy of how to handle the unmatched type on data conversion. The default action is throw Exception and another two value of "DEFAULT_VALUE" and "DEFAULT_VALUE_AND_TRACE" can be specified. </para> </listitem> </varlistentry> </variablelist> <para>There are several scope specified annotations can be used as convenience.</para> <itemizedlist> <listitem> <para>@SessionData</para> </listitem> <listitem> <para>@QueryParam</para> </listitem> <listitem> <para>@PathVar</para> </listitem> <listitem> <para>@HeaderData</para> </listitem> <listitem> <para>@CookieData</para> </listitem> <listitem> <para>@FlashData</para> </listitem> </itemizedlist> <remark>All the above annotation have the same configurable items with the original @ContextData annotation except being fixed with according data scope.</remark> </sect2> <sect2 id="vi-contextdataset"> <title>@ContextDataSet</title> <para>A pojo class annotated by @ContextDataSet will be treated as a variable holder. If the type of a snippet class field or a method parameter is a class annotated by @ContextDataSet, when Asta4D do injection, a new instance will be created at first, then all the fields of current instance will be scanned and all the fields annotated by @ContextData will be injected as same as the snippet class field injection. @ContextDataSet can be used to allocate all of the form data into one single instance as a convenience.</para> <example> <programlisting language="java"> <![CDATA[ @ContextDataSet public static class MySet { @ContextData private long f1; @ContextData private String f2; public long getF1() { return f1; } public String getF2() { return f2; } } public static class MySnippet { public void render(MySet holder) { } } public static class MySnippet2 { @ContextData private MySet holder; public void render() { } } ]]> </programlisting> <para>Note that even you declared @ContextDataSet on the class, you still need to declare the @ContextData on the field declaration. For method parameter, it is not necessary since all the parameters are injected automatically. Further, for a declared @ContextDataSet, you still need to declare @ContextData on every field you want to be injected.</para> </example> <variablelist> <title>Available configurations of @ContextData:</title> <varlistentry> <term>singletonInContext</term> <listitem> <para>A boolean value to indicate that whether the target ContextDataSet should be singleton in a single context life cycle. The default value is false, which means a new instance would be created at every time when a ConextDataSet is required to inject. </para> </listitem> </varlistentry> <varlistentry> <term>factory</term> <listitem> <para>A factory class can be used to indicate how to create an instance of ContextDataSet. The default factory will call Class#newInstance() to create a new instance of ContextDataSet. </para> </listitem> </varlistentry> </variablelist> </sect2> <sect2 id="vi-ContextDataFinder"> <title>ContextDataFinder</title> <para>Asta4D search data in context by pre configured ContextDataFinder implementation. The default implementation is WebApplicationContextDataFinder. You can supply your own search mechanism by implementing the ContextDataFinder interface or extending from WebApplicationContextDataFinder. WebApplicationContextDataFinder defines the scope search order if scope is not specified, and also returns some special data by hard coding type check:</para> <itemizedlist> <listitem> <para>Context/WebApplicationContext</para> </listitem> <listitem> <para>ResourceBundleHelper</para> </listitem> <listitem> <para>ParamMapResourceBundleHelper</para> </listitem> <listitem> <para>HttpServletRequest</para> </listitem> <listitem> <para>HttpServletResponse</para> </listitem> <listitem> <para>ServletContext</para> </listitem> <listitem> <para>UrlMappingRule</para> </listitem> </itemizedlist> <para>The first 3 types are afforded by the parent class of WebApplicationContextDataFinder: DefaultContextDataFinder. To supply your own logic, you can override the findDataInContext method and the WebApplicationContextDataFinder's source can be treated as reference implementation.</para> </sect2> <sect2> <title>DataConvertor</title> </sect2> <sect2> <title>ContextDataHolder</title> </sect2> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,059,145,555,700,351,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-detail-url-rule" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>URL rule</title> <sect1 id="rule-apis"> <title>Rule apis</title> <sect2 id="UrlMappingRuleInitializer"> <title>UrlMappingRuleInitializer</title> <para>All the url mapping rules can be supplied by implementing the UrlMappingRuleInitializer interface which can be configured by WebApplicationConfiguration#setUrlMappingRuleInitializer.</para> <para>UrlMappingRuleInitializer's initUrlMappingRules method does not return configured rules directly, it supply a UrlMappingRuleHelper instance by parameter instead. The UrlMappingRuleHelper afford a group of methods to help developers build url mapping rules.</para> <para>UrlMappingRuleHelper allows add new rule by add methods, which will be discussed in next section, let us see the global configuration methods of UrlMappingRuleHelper at first.</para> <itemizedlist> <listitem> <para>addDefaultRequestHandler(Object... handlerList)</para> </listitem> <listitem> <para>addDefaultRequestHandler(String attribute, Object... handlerList)</para> <sbr/> <para>There are two overloaded methods of addDefaultRequestHandler. Added request handlers without attribute declaration will be applied to all the rules and the ones with attribute declaration will be applied to therules with same attribute only. </para> <sbr/> </listitem> <listitem> <para>addGlobalForward(Object result, String targetPath)</para> </listitem> <listitem> <para>addGlobalForward(Object result, String targetPath, int status) </para> <sbr/> <para>There are two overloaded methods of addGlobalForward. The one with status parameter can customize the http response code with specified status code or the default code 200 will be returned to client.</para> <sbr/> </listitem> <listitem> <para>addGlobalRedirect(Object result, String targetPath) </para> <sbr/> <para>A global redirect result mapping can be declared. There is a convention about the format of target path(the normal redirect on special rules follows the same convention):</para> <itemizedlist> <listitem> <para>common url string("http://www.example.com/somepage.html")</para> <para>The target url will be redirected as temporary(code 302).</para> </listitem> <listitem> <para>common url string with prefix("301:http://www.example.com/somepage.html")</para> <para>The target url will be redirected as specified code by the prefix. 301 or 302 are acceptable and "p" or "t" can be used to represent "permanent" or "temporary" as well(which means "301:http://www.example.com/somepage.html" equals to "p:http://www.example.com/somepage.html").</para> </listitem> </itemizedlist> <sbr/> </listitem> <listitem> <para>addRequestHandlerInterceptor(Object... interceptorList)</para> </listitem> <listitem> <para>addRequestHandlerInterceptor(String attribute, Object... interceptorList)</para> <para><remark>The request handler interceptor is need to be clarified more in the implementation. We skip the description at present.</remark></para> <sbr/> </listitem> <listitem> <para>registerRestTransformer(ResultTransformer transformer)</para> </listitem> <listitem> <para>registerJsonTransformer(ResultTransformer transformer)</para> <para>The returned value of a request handler which is declared as json at rule will be transformed to standard json string, and developers can still register a customized result transformer to generate the response by the own way. Further, even the framework will do nothing on the returned value of a handler if which is declared on a rest rule, developer can still use "registerRestTransformer" to add customized result transforming on a rule declared as rest.</para> <sbr/> </listitem> <listitem> <para>setDefaultMethod(HttpMethod defaultMethod) </para> <para>The default matching http method for url patterns without http method specified. The default value is GET.</para> </listitem> </itemizedlist> </sect2> <sect2> <title>Handy rules</title> <para>There several add methods from UrlMappingRuleHelper which can be used to add new url rules. According to the certain being called add method, different interface which is called handy rules will be returned for further declaration. Further, all the methods of the returned handy rule interface will return different interface according to the certain method you are calling, it is complex to describe which interface will be returned on certain case, basically we suppose that the code auto completion function of you editor would help you to know what you can do in the next step. All of these handy rules and their methods can be treated as a group of DSL to help you build your own url rules for your site. We will describe all the available methods at following regardless of which certain interface it belongs to. After that, we will also describe the basic rule of how the returned handy rules change.</para> <itemizedlist> <listitem> <para>add(String sourcePath)</para> </listitem> <listitem> <para>add(String sourcePath, String targetPath) </para> </listitem> <listitem> <para>add(HttpMethod method, String sourcePath) </para> </listitem> <listitem> <para>add(HttpMethod method, String sourcePath, String targetPath)</para> <sbr/> <para>Add a new url rule. If the http method is not specified. the configured default method(see above setDefaultMethod) will be specified by default. If you want the sourcePath is matched to all the http methods, null can be specified. The targetPath should be a template file path or a redirect target url string with prefix "redirect:", the part after prefix "redirect:" follows the convention of redirect string format introduced in global redirect configuration. </para> <sbr/> </listitem> <listitem> <para>id(String id)</para> <sbr/> <para>One added rule can be identified by a unique id. </para> <sbr/> </listitem> <listitem> <para>reMapTo(String ruleId)</para> <sbr/> <para>Multi url patterns can be mapped to the same rule by reMapTo method. See following sample: </para> <example><title>Remap the rule to a existing rule</title> <programlisting language="java"> <![CDATA[ rules.add("/app/", "/templates/index.html").id("index-page"); rules.add("/app/index").reMapTo("index-page"); rules.add("/app/handler").id("app-handler") .handler(LoginHandler.class) .handler(EchoHandler.class) .forward(LoginFailure.class, "/templates/error.html") .forward("/templates/success.html"); rules.add("/app/ex-handler").reMapTo("app-handler").attribute("ex-handler"); ]]> </programlisting> <para>In above sample, "/app/index" will be treated as same as the rule identified as "index-page" which sourc path is "/app/". Aslo the "/app/ex-handler" will be configured as same as "/app/handler" with its special attribute configuration "ex-handler". Special path variable and priority can be configured to remapped rules as well.</para> </example> <sbr/> </listitem> <listitem> <para>attribute(String attribute)</para> <sbr/> <para>Multi attributes can be configured to a rule. The attributes can be used by global rule configurations to add certain extra operations on certain urls which is attributed by certain attribute. </para> <sbr/> </listitem> <listitem> <para>var(String key, Object value)</para> <sbr/> <para>Static path variables can be configured by this method, that can be accessed by context's path var scope and also can be automatically injected to snippets or request handlers. </para> <sbr/> </listitem> <listitem> <para>handler(Object... handlerList)</para> <sbr/> <para>Request handlers can be configured by this methods. Multi request handlers are acceptable and the details about multi request handlers will be explained in later section.</para> <para>The parameter of handler method can be arbitrary type: an instance of java.lang.Class or an arbitrary instance. The framework explains received parameters by the implementation of DeclareInstanceResolver configured by WebApplicationConfiguration. The default implementation provided by framework follows the following rules to explain the declaration of request handler:</para> <orderedlist> <listitem> <para>If an instance of java.lang.Class is specified, the instance of request handler will be created by invoke "newInstance()" on the specified Class.</para> </listitem> <listitem> <para>If a string is specified, the string will be treated as a class name and an instance of java.lang.Class will be created by calling "Class#forName", then the instance of request handler will be created by invoke "newInstance()" on the created Class.</para> </listitem> <listitem> <para>The specified parameter will be treated as a request handler directly if it is neither a Class nor a string. By this rule, it is interesting that we can declare an anonymous class as a request handler:</para> <example> <programlisting language="java"> <![CDATA[ rules.add("/app/handler") .handler(new Object(){ @RequestHandler public void handle(){ // } }); ]]> </programlisting> </example> </listitem> </orderedlist> <remark>The asta4d-spring package also provides a resolver based on Spring IOC container, the request handler instance will be retrieved by passing the specified parameter to the "Context#getBean" method of spring container. See details of integration of Spring IOC.</remark> <sbr/> </listitem> <listitem> <para>forward(String targetPath)</para> </listitem> <listitem> <para>forward(String targetPath, int status)</para> </listitem> <listitem> <para>forward(Object result, String targetPath)</para> </listitem> <listitem> <para>forward(Object result, String targetPath, int status)</para> <sbr/> <para>The request will be forwarded to the target template file with specified status code. The result parameter will be used to match the result from request handler(if there is any request handler configured for current rule).About result matching, see details in next section. </para> <sbr/> </listitem> <listitem> <para>redirect(String targetPath)</para> </listitem> <listitem> <para>redirect(Object result, String targetPath)</para> <sbr/> <para>As the same as forward, the request will be redirected(301/302) to the target path. The target path string follows the convention of redirect string format introduced in global redirect configuration. </para> <sbr/> </listitem> <listitem> <para>json()</para> <sbr/> <para>The result of request handler will be converted to a json string and be returned the client with MIME type "application/json". </para> <sbr/> </listitem> <listitem> <para>rest()</para> <sbr/> <para>This method does nothing for the current url by default, but declared as a hint that suggests the current rule will act as a restful api and will return customized response which would be head only response in many cases. </para> <sbr/> </listitem> </itemizedlist> </sect2> </sect1> <sect1> <title>Request handler result process</title> <para>This section will describe some internal mechanism of how asta4d handle the result from a request handler. Especially for the part of result transforming, which is not necessary for normal development but can help you understand how the request handler chain works.</para> <sect2> <title>Content provider</title> </sect2> <sect2> <title>Result transforming</title> </sect2> <sect2> <title>Request handler chain</title> </sect2> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-2,331,903,002,063,231,500
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="chapter-best-practice" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Best practice</title> <para>In this chapter, we will introduce the best practice of Asta4D from our own experiences. There are some conventions and assumption in this chapter, absolutely there are always special cases which are out of our assumption, however you can break any rules to handle your special cases, we only discuss the common cases in this chapter. </para> <sect1 id="division-responsibilities"> <title>Division of responsibilities between request handler and snippet</title> <sect2 id="do-update-by-request-handler"> <title>Do update by request handler</title> <para>MUST do all the operations with side effect at request handler side, that is so we called isolating side effect.</para> <para>NEVER do any operations with side effect at snippet side.</para> </sect2> <sect2 id="normalize-page-condition"> <title>Normalize page condition by request handler</title> <para>It is a little bit difficult to explain this rule. For a page, we assume that there are always only 2 types of pages. Let us see how we should divide our logic between the request handler and snippet. </para> <sect3 id="url-of-unique-resource-id"> <title>The URL of current page represents the unique resource id of an entity(resource)</title> <itemizedlist> <listitem> <para>request handler</para> <itemizedlist> <listitem> <para>Retrieve the entity(resource) from back-end storage(usually the db) by given id which is specified by the URL</para> </listitem> <listitem> <para>Decide how/what to response</para> <itemizedlist> <listitem> <para>(for example)If the target entity does not exist, return a 404 to the client</para> </listitem> <listitem> <para>(for example)If the target entity has been changed/migrated to another entity, return a 301 to the client</para> </listitem> <listitem> <para>(usually)Save the entity to Context and then forward to the target html template</para> </listitem> </itemizedlist> </listitem> </itemizedlist> </listitem> <listitem> <para>snippet</para> <itemizedlist> <listitem> <para>Retrieve the saved entity(resource) from Context(by @ContextData)</para> </listitem> <listitem> <para>Perform other necessary query for rendering</para> </listitem> </itemizedlist> </listitem> </itemizedlist> </sect3> <sect3 id="url-of-search-condition-for-list"> <title>The URL of current page represents a search condition which can be used to retrieve a list of entities(resources)</title> <itemizedlist> <listitem> <para>request handler</para> <itemizedlist> <listitem> <para>For simple cases, a request handler is not necessary</para> <para>Because the snippet can retrieve the condition by @ContextData directly. However we recommend to declare a POJO to represent your search condition for a little bit complicated situations. </para> <example> <title>Snippet handling a search condition POJO</title> <programlisting language="java"> <![CDATA[ @ContextDataSet public class Condition{ @QueryParam private String queryword; public String getQueryword(){ return queryword; } } ]]> </programlisting> <programlisting language="java"> <![CDATA[ public class MySnippet{ @ContextData private Condition condition; } ]]> </programlisting> </example> </listitem> <listitem> <para>Normalize the search condition POJO</para> <para>In some complicated situations, you may need to retrieve the POJO in request handler then do some necessary normalization. After the POJO was normalized, you should save it into Context to pass to snippet. </para> <example> <title>Normalize the search condition POJO</title> <programlisting language="java"> <![CDATA[ @ContextDataSet(singletonInContext=true) public class MyHandler{ public static final String SEARCH_CONDITION = "SEARCH_CONDITION#MyHandler"; @RequestHandler public void handle(Condition condition){ //do some normalization here ... //This is not necessary //Context.getCurrentThreadContext().setData(SEARCH_CONDITION, condition); } } ]]> </programlisting> <programlisting language="java"> <![CDATA[ public class MySnippet{ @ContextData private Condition condition; } ]]> </programlisting> <remark>There is a trick that if we define a ContextDataSet's singletonInContext to true, there will be only on single instance in the context, thus we do not need to declare the name of ContextData even we stored the POJO by name at the handler side. Even that you do not need to save the condition POJO explicitly since it is the single instance in the Context.</remark> </example> </listitem> </itemizedlist> </listitem> <listitem> <para>snippet</para> <itemizedlist> <listitem> <para>Retrieve the saved search condition POJO from Context(by @ContextData) or simply declare the search condition as its own fields(by @ContextData)</para> </listitem> <listitem> <para>Perform the query by given search condition to retrieve the list of entities(resources)</para> </listitem> <listitem> <para>Perform other necessary query for rendering</para> </listitem> </itemizedlist> </listitem> </itemizedlist> </sect3> </sect2> </sect1> <sect1 id="common-usage-form-flow"> <title>Common usage of form flow</title> <remark>To be written.</remark> </sect1> <sect1 id="best-snippet-way"> <title>The best way of implementing a snippet</title> <sect2 id="perform-queries-simple"> <title>Perform queries as simple as possible</title> <para>We encourage developers to retrieve the data at the place where the data is required rather than retrieve a complicated data structure which holds all the necessary data for the whole page rendering in bulk. We make a convention that there are only 4 type of return value in our service layer(where the queries are performed exactly): </para> <itemizedlist> <listitem> <para>a single entity which is usually the POJO for ORMAP</para> </listitem> <listitem> <para>an list of entities' ids(not the entities themselves)</para> </listitem> <listitem> <para>a count of some aggregation queries</para> </listitem> <listitem> <para>a map as &lt;id, count&gt; of some aggregation queries</para> </listitem> </itemizedlist> <para>In the implementation of render methods, we always retrieve the entity instance one by one even we are rendering a list of entity (exactly we only have a list of entities' ids). For the concern about performance, see the later description of cache. However, there must be some situations that we cannot be satisfied with the performance by retrieving data in a too small granularity. We handle these cases as following steps: </para> <itemizedlist> <listitem> <para>Ask yourself, is it true that the granularity of data retrieving is the bottleneck of current performance issue.</para> </listitem> <listitem> <para>Ask your team members to confirm the bottleneck again.</para> </listitem> <listitem> <para>Implement a query method which returns a map as &lt;id, entity&gt; in bulk, then retrieve the entity from the map in the list rendering.</para> </listitem> <listitem> <para>If there is still a performance issue, ask yourself and ask your team members to confirm the bottleneck again.</para> </listitem> <listitem> <para>Build a query to retrieve all necessary data in bulk then return a complicated data structure from the query method just like what we are used to do in the traditional MVC mode.</para> </listitem> </itemizedlist> <para>In fact, the complicated data structures are rare in our system and most of our cases can be satisfied with the basic ORMAP entities.</para> </sect2> <sect2 id="make-use-of-parallelRowRender"> <title>Make use of ParallelRowRender</title> <para>The ParallelRowRender splits the rendering action to threads with the size of rendered list. If there are some heavy operations in the list rendering, ParallelRowRender is a good option to reduce the time of rendering.</para> </sect2> <sect2 id="cache-data"> <title>Cache your data</title> <para>Since we are encouraging developers to retrieve data by a small granularity, the cache is very important to the system. Especially we often retrieve entities one by one in the list rendering, the cache of entities is the most important thing for performance. As a matter of fact, we can use the cache more effective because of the small data granularity.</para> </sect2> <sect2 id="avoid-duplicated-query"> <title>Avoid duplicated query</title> <para>An frequently asked question is how to avoid duplicated query in the snippet class. That is actually an problem since we encourage the developers perform queries at the place where the data is required. We have the following options to combat this issue:</para> <itemizedlist> <listitem> <para>Global query lock via AOP</para> <para>This is the first option that we recommend for query heavy systems and exactly what we did in our system before we moved to saas architecture. We split all the real queries to a service layer then perform a global lock for all the equal calling parameters on the same method. We use spring as our IOC container and simply add the lock logic by the spring's AOP mechanism.</para> </listitem> <listitem> <para>ContextBindData</para> <para>For the lighter systems, ContextBindData would be a good choice for most situations. The get method of ContextBindData will be executed only once in the current Context. See the detail of ContextBindData at <xref linkend="vi-ContextDataFinder"/>. </para> <para>ContextBindData can also be used as a graceful simple wrapping mechanism for data retrieving at snippet layer. Developers can declare the common queries of a snippet class as ContextBindData fields of it. </para> </listitem> <listitem> <para>InitializableSnippet</para> <para>A snippt class can also implement an interface called InitializableSnippet. The init() method of a snippet which implements the InitializableSnippet will be called once after the snippet instance is created. Developer can do some prepare work for rendering by this mechanism such as performing common queries. However, performing query in init() method is not recommended but everything is by your choice. </para> <remark>In multiple thread rendering, the snippet classes may still be instantiated multiple times. There is no warranty about it. </remark> </listitem> </itemizedlist> </sect2> <sect2 id="prepare-snippet-instance"> <title>Prepare snippet instance(set default value) by InitializableSnippet</title> <para>As we mentioned above, InitializableSnippet can be used to do some initialization work after the snippet instance is created. We do not recommend to perform common queries in init() method of InitializableSnippet, but the InitializableSnippet interface is still a good option for preparing a snippet instance.</para> <para>The classical usage of InitializableSnippet is that we can set default value of declared @ContextData fields if some of them are set to null.</para> </sect2> <sect2 id="selector-x-convention"> <title>"x-" convention selector</title> <para>Though we can use various selectors to render data into the template file, we recommend to use css class name selector in common cases, which affords the best compatibility to the frond-end refactoring. We also made a convention which is called "x-" convention. we will always add a css class started with "x-" to the data rendering target, which tells the front-end guys try their best to keep the compatibility against the "x-" marked elements when they are refactoring the html sources.</para> <para>Although we always use "x-" convention to render our data, there are still some acceptable exceptions in our practice:</para> <itemizedlist> <listitem> <para>use "a" directly when rendering the link to the "href" attribute</para> </listitem> <listitem> <para>use "img" directly when rendering the link to the "src" attribute</para> </listitem> <listitem> <para>use "li" directly when rendering a list</para> <remark>This one is controversial, some of our members argue that we should use "x-" instead of direct "li" selector.</remark> </listitem> </itemizedlist> </sect2> <sect2 id="remove-rather-than-add"> <title>Remove contents rather than add contents for conditional rendering</title> <para>Sometimes we need to do conditional rendering. For instance, we assume that there are two tabs which can be switched by different query parameter, a possible way is to create the target tab contents dynamically at snippet side as following:</para> <example> <title>create contents dynamically</title> <programlisting language="java"> <![CDATA[ public Renderer render(int id){ Element elem = null; if(id == 0){ elem = ElementUtil.ParseAsSingle("<div>" + id + "</div>"); }else{ elem = ElementUtil.ParseAsSingle("<div class="great">" + id + "</div>"); } return Renderer.create(".x-target", elem); } ]]> </programlisting> </example> <para>Apparently there is bad smell in above example, we generate DOM element at snippet side, which makes front-end refactoring difficult. The recommended way is to write all the possible contents in template file and remove the unnecessary ones in snippet.</para> <example> <title>remove redundant contents</title> <programlisting language="java"> <![CDATA[ public Renderer render(int id){ Renderer renderer = Renderer.create(); //remove the clear mark renderer.add(".x-target-" + id, "-class", "x-clear"); //then clear the left ones which is not necessary renderer.add(".x-clear", Clear); return renderer; } ]]> </programlisting> <programlisting language="xml"> <![CDATA[ <div class="x-target-0 x-clear">0<div> <div class="x-target-1 x-clear">1<div> ]]> </programlisting> </example> </sect2> </sect1> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-160,759,513,130,886,180
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="request_handler" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Request Handler</title> <para>Viewの表示前に処理を行いたい場合に使用します。</para> <programlisting language="java"> <![CDATA[ public class GenericController extends GenericControllerBase { @Override protected void initUrlMappingRules(UrlMappingRuleHelper rules) { rules.add(HttpMethod.POST, "/login/{id}", LoginHandler.class); // (1) } } ]]> </programlisting> <programlisting language="java"> <![CDATA[ public class LoginHandler { @RequestHandler // (2) public String doLogin( @ContextData(scope=WebApplicationContext.SCOPE_PATHVAR) String id) { // ログイン処理の実行(省略) return "/mypage.html"; } } ]]> </programlisting> <para>(1) 「/login/&lt;任意の文字列&gt;」への POST リクエストに、Request Handler としてLoginHandler を使用し、URLに含まれる&lt;任意の文字列&gt;を変数「id」に格納することを定義しています。</para> <para>(2) 「/login/&lt;任意の文字列&gt;」への POST リクエスト時にdoLoginメソッドを実行し、その後mypage.htmlテンプレートを使用してViewのレンダリングを実行します。引数「id」として、URLに含まれる&lt;任意の文字列&gt;をメソッド内で使用することができます。</para> <para>リダイレクトとFlashスコープ:リダイレクトにより画面遷移を行う場合、Flashスコープに設定した値を受け渡すことができます。</para> <programlisting language="java"> <![CDATA[ public class RedirectSampleHandler { @RequestHandler public Object redirect(String name, String age, String bloodtype) { Map<String, Object> flashScopeData = new HashMap<>(); flashScopeData.put("name", name); flashScopeData.put("age", age); flashScopeData.put("bloodtype", bloodtype); return new RedirectView("/profile/input", flashScopeData); // (3) } } ]]> </programlisting> <para>(3) RedirectView の第一引数にリダイレクト先の url を、第二引数にFlashスコープに設定する値のMapを指定しています。「/profile/input」に設定された Request Handler およびテンプレートで指定した Snippet 内で、Flash スコープに設定した値を参照することができます。</para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,040,453,635,419,684,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="template" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Template</title> <para>レンダリングsnippetクラスの宣言:</para> <para>View 層の静的コンテンツとなる HTML ファイルです。テンプレートファイルはデフォルトではWebアプリのDocument Root 以下に配置しますが、/WEB-INF下に指定したい場合には TemplateResolver#searchPath() を指定できます。 テンプレートファイルでは、レンダリングの際に呼び出される Snippet クラスをHTMLタグ内に指定することができます。</para> <programlisting language="php"> <![CDATA[ <html> <head><title>template sample</title></head> <body> <!-- (1) --> <div afd:render="SampleSnippet"> <span>dummy text</span> </div> <!-- (2) --> <div afd:render="SampleSnippet:execute"> <span id="sample" value="1">dummy text</span> <span id="sample_nosymbol" class="text name">text</span> <span id="sample_plus" class="text name">text</span> <span id="sample_minus" class="text name">text</span> <div id="dynamic_snippet"></div> <div id="dynamic_embed"></div> </div> <!-- (3) --> <afd:snippet render="SampleSnippet:embedTag" value="sampleValue"> <span>dummy text</span> </afd:snippet> </body> </html> ]]> </programlisting> <para>(1) 任意のタグの「afd:render」属性に、SampleSnippetクラスをSnippetとして呼び出すことを宣言しています。メソッド名を指定しない場合、 render()メソッドが呼び出されます。(クラス名は完全修飾名で指定することもできます。Configuration#setSnippetResolver()でデフォルトパッケージ を指定することで、パッケージ名を省略することができます。また、Spring MVCとの連携動作をする際、Spring Bean Containerで管理しているBean ID を指定します。)</para> <para>(2) (2) 任意のタグの「afd:render」属性に、SampleSnippetクラスのexecute()メソッドをSnippetとして呼び出すことを宣言しています。 また、子要素のspanタグの属性名や属性値はexecuteメソッド内でレンダリング対照の指定に使用することができます。</para> <para>(3) afd:snippetタグのrender属性に、SampleSnippetクラスのembedTag()メソッドをSnippetとして呼び出すことを宣言しています。また、 value属性はembedTag()メソッドの引数として参照することができます。</para> <para>テンプレートファイルは別のテンプレートファイルを継承することができます。あるテンプレートを継承したテンプレートでは、親となるテンプレートの任意の要素に追加・挿入・上書きを 行うことができます。要素の追加および挿入は、主にHTMLヘッダ情報をマージする目的で使用することを想定しています。</para> <para>parent.html</para> <programlisting language="php"> <![CDATA[ <html> <head> <afd:block id="block1"> <link href="parent1.css" rel="stylesheet" type="text/css" /> </afd:block> <afd:block id="block2"> <link href="parent2.css" rel="stylesheet" type="text/css" /> </afd:block> <title>extension sample</title> </head> <body> <afd:block id="content">content</afd:block> </body> </html> ]]> </programlisting> <para>child.html</para> <programlisting language="php"> <![CDATA[ <html> <head></head> <body> <!-- (1) --> <afd:extension parent="parent.html"> <!-- (2) --> <afd:block append="block1"> <link href="child1.css" rel="stylesheet" type="text/css" /> </afd:block> <!-- (3) --> <afd:block insert="block2"> <link href="child2.css" rel="stylesheet" type="text/css" /> </afd:block> <!-- (4) --> <afd:block override="content "> <div>hello</div> <!-- (5) --> <afd:embed target="/templates/embed.html" ></afd:embed> </afd:block> </afd:extension> </body></html> ]]> </programlisting> <para>embed.html</para> <programlisting language="php"> <![CDATA[ <html> <head></head> <body> <!-- (6) --> <afd:block append="block1"> <link href="embed.css" rel="stylesheet" type="text/css" /> </afd:block> <div>good embed</div> </body></html> ]]> </programlisting> <para>(1) テンプレートファイル「parent.html」を継承することを宣言しています。(子テンプレートに対して、「afd:extension」 宣言以外のものが無視されているので、editor向けのhead情報などを自由に設定することができます)</para> <para>(2) 継承元テンプレートのblock1属性の子要素の後に追加することを宣言しています。レンダリングの結果 「&lt;link href="parent1.css" ... /&gt;&lt;link href="child1.css" ... /&gt;」が出力されます。</para> <para>(3) 継承元テンプレートのblock2属性の子要素の前に挿入することを宣言しています。レンダリングの結果 「&lt;link href="child2.css" ... /&gt;&lt;link href="parent2.css" ... /&gt;」が出力されます。</para> <para>(4) 継承元テンプレートのcontent属性の子要素を上書きすることを宣言しています。レンダリングの結果「&lt;div&gt;hello&lt;/div&gt;」が出力されます。</para> <para>(5) 別のHTMLファイルを埋め込むことを宣言しています。「/templates/embed.html」の内容が埋め込まれてレンダリングされます。</para> <para>(6) embedファイルでも、bodyの部分以外は無視されていますので、エディタ向けののヘッダなどは自由に設定できる。且つ、block宣言があれば、 継承と同じように、引用元のファイルに対象blockを探して、追加もしくは上書きをします。</para> <para>上記のテンプレートファイルのレンダリング結果は下記のようになっている:</para> <programlisting language="php"> <![CDATA[ <html> <head> <!—block1 --> <link href="parent1.css" rel="stylesheet" type="text/css" /> <link href="child1.css" rel="stylesheet" type="text/css" /> <link href="embed.css" rel="stylesheet" type="text/css" /> <!—block2 --> <link href="child2.css" rel="stylesheet" type="text/css" /> <link href="parent2.css" rel="stylesheet" type="text/css" /> <title>extension sample</title> </head> <body> <!—content --> <div>hello</div> <!—embed --> <div>good embed</div> </body> </html> } ]]> </programlisting> <para>afd:clearでマークしている内容はレンダリングする際削除されますので、テンプレートに複数行のデータの表現を表したい場合、 開発側は余計な行に「afd:clear」を入れるので、適当に複数行のHTMLを書いても構いません。</para> <programlisting language="php"> <![CDATA[ <ul> <li class="first"> row 1 <li class="even" afd:clear> row 2 <li class=" odd" afd:clear > row 3 </ul> ]]> </programlisting> <para>HTML5について:</para> <para>使用しているHTML解析ライブラリjsoupはWHATWGのHTML5を準拠している。設計の目的は最大限の互換性を持つことなので、 不正フォーマットがあっても、エラーにならずに自動的に補完して修正する仕様になっている。結果として、テンプレートファイルにもしミスなどの原因で 不正フォーマットがあっても、jsoupがエラーにならずに正常に解析できるようになっており、自動修正の結果は予想通りであれば、画面が正しく表示しますが、 予想通りではない場合、画面がおかしくなることです。</para> <para>特に気を付けなければならないのは、HTML5の基準として、セルフクローズのタグがイリーガルなので、セルフクローズのタグをやめてください。</para> <para>Snippet呼び出し宣言、別ファイル埋め込み宣言はネストさせることができます。ネストしたSnippet呼び出しは、外側のタグに宣言したものから順番に呼び出されます。</para> <programlisting language="php"> <![CDATA[ <html> <head><title>nest sample</title></head> <body> <afd:snippet render="SampleNestSnippet:outer"> <p id="outer"></p> <afd:snippet render="SampleNestSnippet:inner"> <p id="inner"></p> </afd:snippet> <afd:embed target="/templates/nested_embed.html" /> </afd:snippet> </body> </html> ]]> </programlisting> <programlisting language="php"> <![CDATA[ <div id="nested1"></div> <div id="nested2" afd:render="SampleNestSnippet:nestedEmbed"></div> ]]> </programlisting> <para>この場合、outer -> nestedEmbed -> innerの順にレンダリングメソッドが呼び出されます。また、外側のSnippetで設定した属性値を内側のSnippetで 引数として使用することができます。(テンプレートファイルのHTMLタグ属性値をSnippetレンダリングメソッドの引数として扱う方法は3. Snippet を参照してください)</para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
3,505,785,843,370,018,300
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="render" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Renderer</title> <para>Snippetで戻り値として返されるレンダリングデータです。Render属性を定義したタグの子要素の完全置換・CSSセレクタでの条件指定による部分置換などを行うことができます。</para> <programlisting language="java"> <![CDATA[ public class SampleSnippet { public Renderer render() { Element element = ElementUtil.parseAsSingle("<div>replaced element</div>"); return Renderer.create("*", element); // (1) } public Renderer execute() { Renderer renderer = Renderer.create("#sample", "replaced text"); // (2) renderer.add("#sample", "value", "2"); // (3) renderer.add("#sample_nosymbol", "class", "label"); // (4) renderer.add("#sample_plus", "+class", "label"); // (5) renderer.add("#sample_minus", "-class", "text"); // (6) Element subSnippet = new SnippetNode("DynamicSnippet:execute"); renderer.add("#dynamic_snippet", new ChildReplacer(subSnippet)); // (7) Element embed = new EmbedNode("/templates/dynamic_embed.html"); renderer.add("#dynamic_embed", embed); // (8) return renderer; } public Renderer embedTag(String value) { return Renderer.create("span", value); // (9) } } ]]> </programlisting> <para>(1) CSSセレクタとして「*(任意の要素と一致)」、出力する要素として文字列から作成したElementを指定しています。render属性を指定したタグの種類に関わらず、 「&lt;div&gt;replaced element&lt;/div&gt;」に置換して出力します。</para> <para>(2) CSSセレクタとして「#sample(id属性の値がsample)」、出力する要素として文字列を指定しています。</para> <para>(3) id属性の値がsampleであるタグのvalue属性の値に「2」を設定して出力するように指定しています。(2)と(3)の指定により、レンダリングの結果 「&lt;span id="sample" value="2"&gt;replaced text&lt;/span&gt;」が出力されます。</para> <para>(4) id属性の値がsample_nosymbolであるタグのclass属性の値に「label」を設定して出力するように指定しています。レンダリングの結果「&lt;span id="sample_nosymbol" class="label"&gt;text&lt;/span&gt;」が出力されます。</para> <para>(5) 属性名の前に「+」を付与することにより、id属性の値がsample_plusであるタグのclass属性の値に「label」を追加して出力するように指定しています。レンダリングの結果 「&lt;span id="sample_plus" class="text name label"&gt;text&lt;/span&gt;」が出力されます。(属性値の追加はclass属性にのみ作用します。class属性以外に+記号を 付与した場合、記号を付与していない場合と同様に扱われます)</para> <para>(6) 属性名の前に「-」を付与することにより、id属性の値がsample_minusであるタグのclass属性の値から「text」を削除して出力するように指定しています。レンダリングの結果 「&lt;span id="sample_minus" class="name"&gt;text&lt;/span&gt;」が出力されます。(属性値の削除はclass属性にのみ作用します。class属性以外に-記号を付与した場合、 属性ごと削除します)</para> <para>(7) 動的に別のSnippetのレンダリングメソッドを呼び出すことを宣言しています。</para> <para>(8) 動的に別のテンプレートファイルを埋め込むことを宣言しています。</para> <para>(9) CSSセレクタとして「span(タグ名)」、出力する要素として引数valueの値を指定しています。render属性を指定したタグの子要素のspanタグの内容を、render属性を指定したタグのvalue 属性の値に置換して出力します。</para> <para>レンダリングにはjsoupを利用しています。CSSセレクタの詳細な記法はjsoup APIを参照してください。<link xl:href="http://jsoup.org/apidocs/org/jsoup/select/Selector.html">CSS Selector</link></para> <para>特殊なRendererについて:</para> <itemizedlist> <listitem> <para>GothroughRenderer</para> <para>それ自体は何もしない Renderer です。</para> </listitem> <listitem> <para>ChildReplacer</para> <para>該当Elementの子要素全てを置換します。</para> </listitem> <listitem> <para>ClearNode</para> <para>該当Elementを削除します。また、任意のタグに「afd:clear」と宣言することで、レンダリング前にテンプレートから削除することも可能です。</para> </listitem> <listitem> <para>ElementSetter</para> <para>該当Elementに対して任意の操作ができるインタフェースです。特殊なレンダリング動作を行いたい場合にこのインターフェースを実装したレンダリングクラスを作成することで実現できます。</para> </listitem> <listitem> <para>DebugRenderer</para> <para>Renderer#addDebuger(String selector)でDebugRendererを追加することができます。DebugRendererに対して、該当Elementの内容をloggerで出力します。 Selectorを指定しない場合、snippetメソッドを定義したElementを出力対象とします。</para> </listitem> <listitem> <para>任意データ型の属性設定</para> <para>属性を設定する際、String、long, int, booleanはStringとして、そのまま該当Elementの属性に設定しますが、その以外のデータ型の設定も可能です。内部はインスタンスのリファレンスを保持して、 Snippetメソッドの変数に自動適用します(ContextDataを参照)。</para> </listitem> </itemizedlist> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,896,192,387,224,316,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="overview" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Asta4Dの紹介</title> <para>Asta4Dは有名なScalaフレームワークであるLiftからインスピレーションを受け、LiftのJava版のような位置 づけとして開発されました。Scalaを使用している場合にはLiftを選択することを強く推奨しますが、Liftの恩恵を 受けながらもJavaを使用し続けたい場合、Asta4Dが最善の選択肢となりえるでしょう。 </para> <para>過去10年間に、様々なJavaフレームワークが作られてきました。特にMVCアーキテクチャとJSPタグリブ (もしくは他の伝統的なテンプレート技術)により、大幅に開発効率が上がりました。しかし、下記のような事柄が いまだに開発者の頭を悩ませ続けています: </para> <itemizedlist> <listitem> <para>ページソースに動的コードが混在しており、ページの再設計やレイアウト調整を行う妨げになると デザイナーやフロントエンドエンジニアから不満を持たれています。同様に、デザイナーやフロントエンドエンジニア がページの再設計とレイアウト調整を行うたびにページソースに埋め込まれた動的コードの挙動を壊してしまう ことがバックエンドエンジニアの不満になります。ソースのリファクタリングに大きなコストかけてまでページの再設計 や新しいページの設計に合わせることは困難であるためです。</para> </listitem> <listitem> <para>開発者は、テンプレート言語の機能が貧弱であることに不満を抱いており、複雑なレンダリングロジックの ために様々なおまじないのようなコードを書くことに疲れています。</para> </listitem> <listitem> <para>開発者はMVCアーキテクチャの生産性が高くないことに不満を抱いており、PHPやASPのようなより効率の良い 手法を求めています。</para> </listitem> </itemizedlist> <para>Asta4Dはこれらの問題点に対するソリューションです。我々はLiftからたくさんのことを学び、それらをJavaの世界に もたらそうと試みています。Asta4Dは下記の点に焦点を当て作られました。 </para> <itemizedlist> <listitem> <para>テンプレートとレンダリングの分離</para> <para>テンプレートファイルには動的なコードが含まれません。Asta4Dのテンプレートファイルは常にフロントエンドエンジニアが メンテナンスし易い純粋なHTMLファイルです。非常にデザインフレンドリーであり、我々はソースリファクタリングに要する作業負荷を 90%以上減らすことができます。 </para> <programlisting language="xml"> <![CDATA[ <section> <article> <div afd:render="SimpleSnippet">dummy text</div> <afd:snippet render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> </article> </section> ]]> </programlisting> <para>レンダリングロジックは独立なJavaクラスで実装していますので、開発者は新しいテンプレート言語の習得が要らなく、 いつも慣れているJavaのままで開発し、Java言語のフールパワーを利用できる。 </para> <programlisting language="java"> <![CDATA[ public class SimpleSnippet { public Renderer render(String name) { if (StringUtils.isEmpty(name)) { name = "Asta4D"; } Element element = ElementUtil.parseAsSingle("<span>Hello " + name + "!</span>"); return Renderer.create("*", element); } public Renderer setProfile() { Renderer render = new GoThroughRenderer(); render.add("p#name span", "asta4d"); render.add("p#age span", "20"); return render; } } ]]> </programlisting> </listitem> <listitem> <para>コントローラを必要としないView Firstと使いやすURLマッチング仕組み</para> <para>我々はMVCアーキテクチャが偉大でパワフルであると考えていますが、生産性が高くはないとも考えています。長年Javaエンジニアは PHPやASPのようなより効率の良い手法を求め続けていました。伝統的なPHP/ASPでの開発が効率が良い理由は「View First」と呼ばれる 解決策によるものです。View Firstの開発スタイルでは、開発者はPHP/ASPの伝統的な開発方法と同じようにページの表示結果を前提として ロジックを実装します。 </para> <para>多くの人は表示結果を前提とした場所に動的コードを実装することは、ソースがより複雑になり理解が困難になると言うかもしれません。 その主張は間違ってはいませんが、Asta4Dではテンプレートファイルとレンダリングロジックとを分離しているため問題となりません。生産性の面では、 開発者は複雑なソースの構成を気にすることなく本質的な開発に専念することができます。 </para> <para>同時に、Asta4Dは使いやすいURLマッチングルールを設定するAPIも提供しています。</para> <programlisting language="java"> <![CDATA[ rules.add("/app/", "/templates/index.html"); rules.add("/app/handler") .handler(LoginHandler.class) .handler(EchoHandler.class) .forward(LoginFailure.class, "/templates/error.html") .forward("/templates/success.html"); ]]> </programlisting> </listitem> <listitem> <para>簡単かつ柔軟な処理フロー</para> <para>Asta4Dには、コントローラがありません。特定のRequestに対して、特定な責任者があると考えて、 request handlerという仕組みを用意しています。request handlerはいつも特定のrequestによって 特定な結果をクライアントに戻そうと担当している部品です。</para> <para>そして、AjaxもしくはRestfulのRequestは簡単にrequest handlerに任せられます。</para> <para>JSON:</para> <programlisting language="java"> <![CDATA[ rules.add("/app/ajax/getUserList").handler(GetUserListHandler.class).json(); //... public class GetUserListHandler { @RequestHandler public List<String> queryUserList() { return Arrays.asList("otani", "ryu", "mizuhara"); } } ]]> </programlisting> <para>Restful:</para> <programlisting language="java"> <![CDATA[ rules.add(PUT, "/app/ajax/addUser").handler(AddUserHandler.class).rest(); //... public class AddUserHandler { @RequestHandler public HeaderInfo doAdd(String newUserName) { // some logic that should add a new user by the given name // ... return new HeaderInfo(200); } } ]]> </programlisting> </listitem> <listitem> <para>request handlerを用いた副作用の分離とマルチスレッドレンダリング</para> <para>システム上に「副作用を伴う挙動」と「副作用を伴わない挙動」と呼ばれている二つタイプの操作があります。 システムの状態を変更するような作用のある挙動を、「副作用を伴う挙動」と呼ぶことにします。例えば、同じURLに対して ログインチェックが行われる場合、ログイン前と認証に成功したログイン後ではおそらく異なるページが表示されるでしょう。 このようなログイン処理は「副作用を伴う挙動」です。また別の分かりやすい例としては、データベース更新処理があります。 更新処理がコミットされれば、それに関連したページは更新処理前とは異なる表示をするでしょう。これもまた「副作用を伴う 挙動」の一種です。データベース検索処理はどうでしょうか。検索処理は副作用を伴わない挙動です。これは何回検索処理を 行ったかに関わらず、常に同じ結果を返すことを意味しています。</para> <para>我々は、その「副作用」を慎重的に管理するべきと思い、全部の「副作用」をrequest handlerの仕組みで管理し、 ビュー層の機能を純粋にし、ソースをより綺麗でメンテナンスし易くするようになっています。これは、Asta4Dがひとつのページを マルチスレッドでレンダリングすることを容易にすることも意味しています。なぜなら、レンダリング処理は副作用から解放されているからです。 </para> <para>並行的なsnippetレンダリング</para> <programlisting language="php"> <![CDATA[ <div afd:render="ParallelTest$TestRender:snippetInDiv" afd:parallel> <div id="test">xx</div> </div> <afd:snippet render="ParallelTest$TestRender:snippetReplaceDiv" parallel> <div id="test">xx</div> </afd:snippet> ]]> </programlisting> <para>並行的なリストレンダリング</para> <programlisting language="java"> <![CDATA[ Renderer renderer = Renderer.create("div#test", list, new ParallelDataConvertor<String, String>() { @Override public String convert(String obj) { try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } return obj + "-sleep"; } }); ]]> </programlisting> </listitem> </itemizedlist> <para>Asta4Dの将来の方向性は、フルスタックのWeb フレームワークですが、初期の段階ではSpring MVCと結合して利用する方針をとっています。 開発を行う際、Asta4Dではサポートしていない機能があれば、Spring MVCに任せて実装する方針です。</para> <para>現在、Asta4Dは三つの部分に分けて実装しています。</para> <itemizedlist> <listitem><para>Asta4D Core: テンプレートエンジン</para></listitem> <listitem><para>Asta4D Web: View Firstの仕組み</para></listitem> <listitem><para>Asta4D Spring: Spring MVCとの連携動作</para></listitem> </itemizedlist> <para>まず、全体構造図を参考してください。簡単な説明は構造図に記載しているため、ここではいくつかの部分のみに追加説明をします。</para> <itemizedlist> <listitem><para>URL Mapping Rule Extractor: 今回、解析文法はSpring3の@RequestMappingルールを流用し、Antのパス宣言文法を利用します。</para></listitem> <listitem> <para>Request Handler: テンプレートに移す前に、画面表示に関係のない更新処理などはこちらに対応できます。</para> <para>※副作用という観点から見ると、テンプレート表示は副作用がなく、DB更新・ログイン処理などは副作用があります。そして、 副作用のある処理はRequest Handlerで対応するという考え方になります。</para> </listitem> <listitem> <para>Renderer:生のテンプレートファイルの内容に対してどの部分はどのようにレンダリングするかということをSnippet Method で定義するクラスです。CSS Selectorでレンダリング対象を宣言してから動作を設定します。Rendererで設定できる動作はテキスト設定、 属性設定、css class追加、css class削除、DOM Node削除、DOM Node書き換えなどがあります。また、リストベースでの動作もできます。 (詳しくは後述します)</para> </listitem> </itemizedlist> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,240,441,034,290,498,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="contextdata" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>ContextDataと変数注入</title> <para>Snippetのレンダリングメソッド、およびRequest Handlerのハンドルメソッドで変数として扱うデータについて定義するアノテーションです。変数の名前やスコープなどを指定することができます。</para> <itemizedlist> <listitem> <para>SnipetもしくはRequestHandlerのメソッドに注入する</para> <programlisting language="java"> <![CDATA[ public class ContextDataSampleSnippet { // (1) public Renderer getPathVarName( @ContextData(name = "count", scope = WebApplicationContext.SCOPE_PATHVAR) int count) { } // (2) public Renderer getQueryParamName( @ContextData(name = "var", scope = WebApplicationContext.SCOPE_QUERYPARAM) String name) { } // (3) public Renderer getDefaultName(String name) { } } ]]> </programlisting> <para>(1) GenericController#initUrlMappingRules()で「/xxx/{count}」と宣言しパス変数に格納した値を引数「count」として扱うよう定義しています。 (データ型を int に自動変換しています。)</para> <para>(2) リクエストパラメータ「xxx.html?var=xxx」として渡された値を引数「name」として扱うよう定義しています。</para> <para>(3) ContextDataアノテーションを定義していないため、最も狭いスコープから順番に変数名「name」と一致する値を探し、引数として扱います。</para> </listitem> <listitem> <para>Snippetのフィールドに注入と初期化(InitializableSnippet)</para> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { @ContextData private String value; // (1) private long id; private String resolvedValue; private int count = 0; @Override public void init() throws SnippetInvokeException { //(2) resolvedValue = value + "-resolved"; count++; } @ContextData private void setId(long id) { //(3) this.id = id; } public Renderer render_1() { return Renderer.create(".value", resolvedValue) .add(".count", count); } public Renderer render_2() { return Renderer.create(".value", resolvedValue) .add(".count", count); } } ]]> </programlisting> <para>(1) 毎回Snippetメソッドを呼び出されている前に、@Contextで宣言しているフィールドをContextからの値で設定します。</para> <para>(2) SnippetクラスのインスタンスはRequestごとにSingletonになっており、初めて呼ばれている場合、かつ、InitializableSnippetインタフェースを宣言している場合、initメソッドが一回呼ばれます。</para> <para>(3) setterでも宣言することが可能です。</para> <para>リバース注入</para> <programlisting language="java"> <![CDATA[ public class InitSnippet implements InitializableSnippet { @ContextData(scope = WebApplicationContext.SCOPE_REQUEST, reverse = true) private String reverseTest; } ]]> </programlisting> <para>フィールドもしくはgetterメソッドで@Contextで明示的にRequestスコープを指定してreverseをtrueに設定すれば、snippetメソッドの実行が完了した後に、 該当フィールドの値を逆にContextに自動保存します。</para> </listitem> <listitem> <para>変数スコープの自動サーチについて</para> <para>@ContextDataでスコープを指定していない場合、特定の順番でサーチします。HTMLタグの属性(snippetを宣言している該当Elementから一番外側の親Elementまで探す、 Snippetのレンダリングメソッドのみ有効)・パス変数・リクエストパラメータ・Flashスコープ変数・クッキー・リクエストヘッダ・リクエスト変数・セッション・グローバル変数の順です。(ここでのリクエスト 変数・グローバル変数とは、Context.setData()から設定して使用する値です)。また、この順番は DefaultContextDataFinder#setDataSearchScopeOrder() で任意に変更することができます。</para> </listitem> </itemizedlist> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-4,972,587,469,037,777,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="snippet" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Snippet</title> <para>View層の動的出力部分です。テンプレートファイルに定義されたメソッドが呼び出されます。Rendererを返すレンダリングメソッドを定義します。</para> <programlisting language="java"> <![CDATA[ public class SampleSnippet { public Renderer render() { // (1) Element element = ElementUtil.parseAsSingle("<div>replaced element</div>"); return Renderer.create("*", element); } public Renderer execute() { // (2) Renderer renderer = Renderer.create("#sample", "replaced text"); renderer.add("#sample", "value", "2"); renderer.add("#sample_nosymbol", "class", "label"); renderer.add("#sample_plus", "+class", "label"); renderer.add("#sample_minus", "-class", "text"); Element subSnippet = new SnippetNode("DynamicSnippet:execute"); renderer.add("#dynamic_snippet", new ChildReplacer(subSnippet)); Element embed = new EmbedNode("/templates/dynamic_embed.html"); renderer.add("#dynamic_embed", embed); return renderer; } public Renderer embedTag(String value) { // (3) return Renderer.create("span", value); } } ]]> </programlisting> <para>(1) テンプレートファイルの任意のタグもしくはafd:snippetタグのrender属性でメソッド名を指定しない場合に呼び出されます。</para> <para>(2) 「&lt;クラス名&gt;:execute」と指定した場合に呼び出されます。</para> <para>(3) 「&lt;クラス名&gt;:embedTag」と指定した場合に呼び出されます。また、render属性を定義したタグのvalue属性の値が引数value の値に格納されます。(テンプレートファイルのタグ属性名と一致するレンダリングメソッドの引数に値が格納されます)</para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,497,036,140,415,773,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="interceptor" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>Interceptor</title> <para>Request Interceptor(要補足)</para> <para>Page Interceptor</para> <para>ページのレンダリング処理前後に処理を行いたい場合に使用します。インターフェースPageInterceptorを実装したクラスをConfiguration#setPageInterceptorList()で設定します。</para> <programlisting language="java"> <![CDATA[ public class SamplePageInterceptor implements PageInterceptor { @Override public void prePageRendering(Renderer renderer) { // (1) // ページレンダリング前の処理(省略) } @Override public void postPageRendering(Renderer renderer) { // (2) // ページレンダリング後の処理(省略) } } ]]> </programlisting> <para>(1) ページレンダリング前に実行されます。</para> <para>(2) ページレンダリング後に実行されます。prePageRenderingおよびレンダリング処理で例外が発生した場合、実行されません。</para> <para>Snippet Interceptor</para> <para>Snippetのメソッド実行前後に処理を行いたい場合に使用します。インターフェースSnippetInterceptorを実装したクラスを DefaultSnippetInvoker.setSnippetInterceptorList ()で設定します。</para> <programlisting language="java"> <![CDATA[ public class SampleSnippetInterceptor implements SnippetInterceptor { @Override public boolean beforeProcess( // (1) SnippetExecutionHolder executionHolder) throws Exception { // Snippetメソッド実行前の処理(省略) return true; } @Override public void afterProcess( // (2) SnippetExecutionHolder executionHolder, ExceptionHandler exceptionHandler) { // Snippetメソッド実行後の処理(省略) } } ]]> </programlisting> <para>(1) Snippetメソッド実行前に実行されます。戻り値としてfalseを返すとSnippetメソッドおよびafterProcessは実行されません。</para> <para>(2) Snippetメソッド実行後に実行されます。ExceptionHandlerでbreforePrcessもしくはsnippetメソッドの実行中に発生した例外の情報を持っており、ExceptionHandler#setException(null) を設定することより例外を取り消すことができます。取り消しを行わない場合、afterProcess実行後にこの例外は上に投げられます。</para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
6,294,718,131,915,898,000
<?xml version="1.0" encoding="UTF-8"?> <chapter xml:id="controller" xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"> <title>GenericController</title> <para>URL とテンプレートファイルとの紐付けや、Request Handlerの設定などを行います。抽象クラスGenericControllerBase を継承し、抽象メソッドinitUrlMappingRules()を実装します。</para> <para>まず、URLとレンダリング先のマッチング関係を指定できます。URLのパースには Spring の AntPathMatcher を利用しています。 詳細な記法は<link xl:href="http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/util/AntPathMatcher.html">Spring API</link>を参照してください。 </para> <programlisting language="java"> <![CDATA[ public class GenericControllerSample extends GenericControllerBase { @Override protected void initUrlMappingRules(UrlMappingRuleHelper rules) { rules.add("/search/company", "/index_search.html"); // (1) rules.add("/search/q/{query}", "/search/result_company.html");// (2) rules.add("/search/q/**/{query}", "/search.html") .var("ex", "query") .method(POST) .priority(-100); // (3) … } } ]]> </programlisting> <para>(1) 「/index」へのリクエストにテンプレートファイルとして index.html を使用することを定義しています。Methodを指定しない場合、 デフォルトメソッドとしてGETが設定されます。UrlMappingRuleHelper# setDefaultMethod() でデフォルトメソッドを変更することができます。</para> <para>(2) 「/search/q/{任意の文字列}」へのリクエストにテンプレートファイルとして search.html を使用し、URLに含まれる{任意の文字列} を変数「query」に格納することを定義しています。格納した変数は、Snippet で使用することができます。</para> <para>(3) 「/search/q/{任意のパス}/{任意の文字列}」へのリクエストにテンプレートファイルとして search.html を使用し、URLに含まれる{任意の文字列} を変数「query」に格納することを定義しています。また、var() で追加変数の宣言、method() でPOSTの指定、priority() でこのルールの優先度を指定しています。</para> <para>RequestHanlderについて:</para> <programlisting language="java"> <![CDATA[ public class GenericControllerSample extends GenericControllerBase { @Override protected void initUrlMappingRules(UrlMappingRuleHelper rules) { rules.add(POST, "/profile/complete", ProfileSendHandler.class); // (4) rules.add(GET, "/login", "/login.html", LoginHandler.class); // (5) rules.add("/login/xx", ProfileSendHandler.class, LoginHandler.class); // (6) … } } ]]> </programlisting> <para>(4) 「/profile/complete」への POST リクエストに、ProfileSendHandlerで処理を行うことを定義しています。 遷移先はProfileSendHandlerの戻り値で決定します。</para> <para>(5) 「/login」への GET リクエストに、LoginHandler で処理を行うことを定義しています。LoginHandlerの戻り値がない場合、 指定されている「/login.html」をデフォルト遷移先としてレンダリングします。(RequestHandlerの戻り値がない場合に限り、ルールで指定している 遷移先を参照します)</para> <para>(6) RequestHandlerを複数指定し、チェーンとして順次処理を行うことを定義しています。チェーン内の途中にあるRequestHandler が遷移先を返すと、後続の処理を続けず返された遷移先に遷移します。</para> <para>リダイレクトについて:</para> <programlisting language="java"> <![CDATA[ public class GenericControllerSample extends GenericControllerBase { @Override protected void initUrlMappingRules(UrlMappingRuleHelper rules) { rules.add( "/redirect", "http://astamuse.com/", RedirectHandler.class); // (7) rules.add("/redirect", "http://astamuse.com/").redirect(); // (8) } } ]]> </programlisting> <para>(7) ビルトインのRedirectHandlerを使用して、遷移先にリダイレクトする(HTTP 302を戻す)ことを定義しています。</para> <para>(8) 同様の処理をredirect()メソッドを使用して定義しています。</para> <para>handler()メソッドについて:</para> <programlisting language="java"> <![CDATA[ public class GenericControllerSample extends GenericControllerBase { @Override protected void initUrlMappingRules(UrlMappingRuleHelper rules) { rules.add("/example/patentlist/xxx/fff", "/patentlist.html", LoginHandler.class, ProfileSendHandler.class).handler( new Object() { @RequestHandler public void go() { // do nothing } }) .handler(LoginHandler.class) .handler(ProfileSendHandler.class);// (9)… } } ]]> </programlisting> <para>(9) handler()メソッドでRequestHandlerを追加設定することが可能です。</para> </chapter>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
3,673,791,566,625,448,000
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl" version='1.0'> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/> <xsl:import href="html.xsl"/> <xsl:param name="html.stylesheet">css/manual-singlepage.css</xsl:param> </xsl:stylesheet>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,820,141,483,984,399,000
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl" version='1.0'> <!-- import the main stylesheet, here pointing to fo/docbook.xsl --> <xsl:import href="urn:docbkx:stylesheet"/> <!-- highlight.xsl must be imported in order to enable highlighting support, highlightSource=1 parameter is not sufficient --> <xsl:import href="urn:docbkx:stylesheet/highlight.xsl"/> <xsl:import href="common.xsl"/> <!-- Extensions --> <xsl:param name="fop1.extensions" select="1"/> <!-- resize the admon graphics. they're width 36pt by default even though the graphics that ship with docbook are 24x24 --> <xsl:template match="*" mode="admon.graphic.width"> <xsl:param name="node" select="."/> <xsl:text>13pt</xsl:text> </xsl:template> <xsl:param name="paper.type" select="'A4'"/> <xsl:param name="page.margin.top" select="'1cm'"/> <xsl:param name="region.before.extent" select="'1cm'"/> <xsl:param name="body.margin.top" select="'1.5cm'"/> <xsl:param name="body.margin.bottom" select="'1.5cm'"/> <xsl:param name="region.after.extent" select="'1cm'"/> <xsl:param name="page.margin.bottom" select="'1cm'"/> <xsl:param name="title.margin.left" select="'0cm'"/> <!-- TITLE PAGE --> <!--xsl:template name="book.titlepage.recto"> <fo:block> <fo:table table-layout="fixed" width="175mm"> <fo:table-column column-width="175mm"/> <fo:table-body> <fo:table-row> <fo:table-cell text-align="center"> <fo:block> <fo:external-graphic src="images/logo.png" width="240px" height="auto" content-width="scale-to-fit" content-height="scale-to-fit" content-type="content-type:image/png" text-align="center" /> </fo:block> <fo:block font-family="Helvetica" font-size="20pt" font-weight="bold" padding="10mm"> <xsl:value-of select="bookinfo/title"/> </fo:block> <fo:block font-family="Helvetica" font-size="14pt" padding-before="2mm"> <xsl:value-of select="bookinfo/subtitle"/> </fo:block> <fo:block font-family="Helvetica" font-size="14pt" padding="2mm"> <xsl:value-of select="bookinfo/releaseinfo"/> </fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell text-align="center"> <fo:block font-family="Helvetica" font-size="14pt" padding="5mm"> <xsl:value-of select="bookinfo/pubdate"/> </fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell text-align="center"> <fo:block font-family="Helvetica" font-size="10pt" padding="10mm"> <xsl:for-each select="bookinfo/authorgroup/author"> <xsl:if test="position() > 1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:value-of select="."/> </xsl:for-each> </fo:block> <fo:block font-family="Helvetica" font-size="10pt" padding="5mm"> <xsl:value-of select="bookinfo/pubdate"/> </fo:block> <fo:block font-family="Helvetica" font-size="10pt" padding="5mm"> <xsl:text>Copyright &#xA9; </xsl:text><xsl:value-of select="bookinfo/copyright"/> </fo:block> <fo:block font-family="Helvetica" font-size="8pt" padding="1mm"> <xsl:value-of select="bookinfo/legalnotice"/> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </xsl:template--> <!-- Prevent blank pages in output --> <xsl:template name="book.titlepage.before.verso"> </xsl:template> <xsl:template name="book.titlepage.verso"> </xsl:template> <xsl:template name="book.titlepage.separator"> </xsl:template> <!-- HEADER --> <!-- More space in the center header for long text --> <xsl:attribute-set name="header.content.properties"> <xsl:attribute name="font-family"> <xsl:value-of select="$body.font.family"/> </xsl:attribute> <xsl:attribute name="margin-left">-5em</xsl:attribute> <xsl:attribute name="margin-right">-5em</xsl:attribute> </xsl:attribute-set> <xsl:template name="header.content"> <xsl:param name="pageclass" select="''"/> <xsl:param name="sequence" select="''"/> <xsl:param name="position" select="''"/> <xsl:param name="gentext-key" select="''"/> <xsl:variable name="Version"> <xsl:choose> <xsl:when test="//productname"> <xsl:value-of select="//productname"/><xsl:text> </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Asta4D User Guide</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="$sequence='blank'"> <xsl:choose> <xsl:when test="$position='center'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$pageclass='titlepage'"> </xsl:when> <xsl:when test="$position='center'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- FOOTER--> <xsl:template name="footer.content"> <xsl:param name="pageclass" select="''"/> <xsl:param name="sequence" select="''"/> <xsl:param name="position" select="''"/> <xsl:param name="gentext-key" select="''"/> <xsl:variable name="Version"> <xsl:choose> <xsl:when test="//releaseinfo"> <xsl:value-of select="//releaseinfo"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="Title"> <xsl:value-of select="//title"/> </xsl:variable> <xsl:choose> <xsl:when test="$sequence='blank'"> <xsl:choose> <xsl:when test="$double.sided != 0 and $position = 'left'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:when test="$double.sided = 0 and $position = 'center'"> </xsl:when> <xsl:otherwise> <fo:page-number/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$pageclass='titlepage'"> </xsl:when> <xsl:when test="$double.sided != 0 and $sequence = 'even' and $position='left'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided != 0 and $sequence = 'odd' and $position='right'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided = 0 and $position='right'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided != 0 and $sequence = 'odd' and $position='left'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:when test="$double.sided != 0 and $sequence = 'even' and $position='right'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:when test="$double.sided = 0 and $position='left'"> <xsl:value-of select="$Version"/> </xsl:when> <xsl:when test="$position='center'"> <xsl:value-of select="$Title"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="processing-instruction('hard-pagebreak')"> <fo:block break-before='page'/> </xsl:template> <!-- PAPER & PAGE SIZE --> <!-- Paper type, no headers on blank pages, no double sided printing --> <xsl:param name="double.sided">0</xsl:param> <xsl:param name="headers.on.blank.pages">0</xsl:param> <xsl:param name="footers.on.blank.pages">0</xsl:param> <!-- FONTS & STYLES --> <xsl:param name="hyphenate">false</xsl:param> <!-- Default Font size --> <xsl:param name="body.font.family">Helvetica</xsl:param> <xsl:param name="body.font.master">10</xsl:param> <xsl:param name="body.font.small">8</xsl:param> <xsl:param name="title.font.family">Helvetica</xsl:param> <!-- Line height in body text --> <xsl:param name="line-height">1.4</xsl:param> <!-- Chapter title size --> <xsl:attribute-set name="chapter.titlepage.recto.style"> <xsl:attribute name="text-align">left</xsl:attribute> <xsl:attribute name="font-weight">bold</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master * 1.8"/> <xsl:text>pt</xsl:text> </xsl:attribute> </xsl:attribute-set> <!-- Why is the font-size for chapters hardcoded in the XSL FO templates? Let's remove it, so this sucker can use our attribute-set only... --> <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode"> <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" xsl:use-attribute-sets="chapter.titlepage.recto.style"> <xsl:call-template name="component.title"> <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/> </xsl:call-template> </fo:block> </xsl:template> <!-- Sections 1, 2 and 3 titles have a small bump factor and padding --> <xsl:attribute-set name="section.title.level1.properties"> <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute> <xsl:attribute name="space-before.minimum">0.8em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master * 1.5"/> <xsl:text>pt</xsl:text> </xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="section.title.level2.properties"> <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute> <xsl:attribute name="space-before.minimum">0.6em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master * 1.25"/> <xsl:text>pt</xsl:text> </xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="section.title.level3.properties"> <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute> <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master * 1.0"/> <xsl:text>pt</xsl:text> </xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="section.title.level4.properties"> <xsl:attribute name="space-before.optimum">0.3em</xsl:attribute> <xsl:attribute name="space-before.minimum">0.3em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.3em</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master * 0.9"/> <xsl:text>pt</xsl:text> </xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <!-- TABLES --> <!-- Some padding inside tables --> <xsl:attribute-set name="table.cell.padding"> <xsl:attribute name="padding-left">4pt</xsl:attribute> <xsl:attribute name="padding-right">4pt</xsl:attribute> <xsl:attribute name="padding-top">4pt</xsl:attribute> <xsl:attribute name="padding-bottom">4pt</xsl:attribute> </xsl:attribute-set> <!-- Only hairlines as frame and cell borders in tables --> <xsl:param name="table.frame.border.thickness">0.1pt</xsl:param> <xsl:param name="table.cell.border.thickness">0.1pt</xsl:param> <!-- LABELS --> <!-- Label Chapters and Sections (numbering) --> <xsl:param name="chapter.autolabel" select="1"/> <xsl:param name="section.autolabel" select="1"/> <xsl:param name="section.autolabel.max.depth" select="1"/> <xsl:param name="section.label.includes.component.label" select="1"/> <xsl:param name="table.footnote.number.format" select="'1'"/> <!-- PROGRAMLISTINGS --> <!-- Verbatim text formatting (programlistings) --> <xsl:attribute-set name="monospace.verbatim.properties"> <xsl:attribute name="font-size">8pt</xsl:attribute> <xsl:attribute name="wrap-option">wrap</xsl:attribute> <xsl:attribute name="keep-together.within-column">always</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="verbatim.properties"> <xsl:attribute name="space-before.minimum">1em</xsl:attribute> <xsl:attribute name="space-before.optimum">1em</xsl:attribute> <xsl:attribute name="space-before.maximum">1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> <xsl:attribute name="border-color">#444444</xsl:attribute> <xsl:attribute name="border-style">solid</xsl:attribute> <xsl:attribute name="border-width">0.1pt</xsl:attribute> <xsl:attribute name="padding-top">0.5em</xsl:attribute> <xsl:attribute name="padding-left">0.5em</xsl:attribute> <xsl:attribute name="padding-right">0.5em</xsl:attribute> <xsl:attribute name="padding-bottom">0.5em</xsl:attribute> <xsl:attribute name="margin-left">0.5em</xsl:attribute> <xsl:attribute name="margin-right">0.5em</xsl:attribute> </xsl:attribute-set> <!-- Shade (background) programlistings --> <xsl:param name="shade.verbatim">1</xsl:param> <xsl:attribute-set name="shade.verbatim.style"> <xsl:attribute name="background-color">#F0F0F0</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="list.block.spacing"> <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-before.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.1em</xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="example.properties"> <xsl:attribute name="space-before.minimum">0.5em</xsl:attribute> <xsl:attribute name="space-before.optimum">0.5em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.5em</xsl:attribute> <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute> <xsl:attribute name="keep-together.within-column">always</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="sidebar.properties"> <xsl:attribute name="border-color">#444444</xsl:attribute> <xsl:attribute name="border-style">solid</xsl:attribute> <xsl:attribute name="border-width">0.1pt</xsl:attribute> <xsl:attribute name="background-color">#F0F0F0</xsl:attribute> </xsl:attribute-set> <!-- TITLE INFORMATION FOR FIGURES, EXAMPLES ETC. --> <xsl:attribute-set name="formal.title.properties" use-attribute-sets="normal.para.spacing"> <xsl:attribute name="font-weight">normal</xsl:attribute> <xsl:attribute name="font-style">italic</xsl:attribute> <xsl:attribute name="font-size"> <xsl:value-of select="$body.font.master"/> <xsl:text>pt</xsl:text> </xsl:attribute> <xsl:attribute name="hyphenate">false</xsl:attribute> <xsl:attribute name="space-before.minimum">0.1em</xsl:attribute> <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute> <xsl:attribute name="space-before.maximum">0.1em</xsl:attribute> </xsl:attribute-set> <!-- CALLOUTS --> <!-- don't use images for callouts --> <xsl:param name="callout.graphics">0</xsl:param> <xsl:param name="callout.unicode">1</xsl:param> <!-- Place callout marks at this column in annotated areas --> <xsl:param name="callout.defaultcolumn">90</xsl:param> <!-- MISC --> <!-- Placement of titles --> <xsl:param name="formal.title.placement"> figure after example after equation before table before procedure before </xsl:param> <!-- Format Variable Lists as Blocks (prevents horizontal overflow) --> <xsl:param name="variablelist.as.blocks">1</xsl:param> <xsl:param name="body.start.indent">0pt</xsl:param> <!-- Remove "Chapter" from the Chapter titles... --> <xsl:param name="local.l10n.xml" select="document('')"/> <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"> <l:l10n language="en"> <l:context name="title-numbered"> <l:template name="chapter" text="%n.&#160;%t"/> <l:template name="section" text="%n&#160;%t"/> </l:context> <l:context name="title"> <l:template name="example" text="Example&#160;%n&#160;%t"/> </l:context> </l:l10n> </l:i18n> <xsl:param name="ulink.footnotes">true</xsl:param> <!-- COLORED AND HYPHENATED LINKS --> <xsl:template match="ulink"> <fo:basic-link external-destination="{@url}" xsl:use-attribute-sets="xref.properties" text-decoration="underline" color="blue"> <xsl:choose> <xsl:when test="count(child::node())=0"> <xsl:value-of select="@url"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </fo:basic-link> </xsl:template> <xsl:template match="link"> <fo:basic-link internal-destination="{@linkend}" xsl:use-attribute-sets="xref.properties" text-decoration="underline" color="blue"> <xsl:choose> <xsl:when test="count(child::node())=0"> <xsl:value-of select="@linkend"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </fo:basic-link> </xsl:template> <!-- SYNTAX HIGHLIGHT --> <xsl:template match='xslthl:keyword' mode="xslthl"> <fo:inline font-weight="bold" color="#7F0055"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> <xsl:template match='xslthl:string' mode="xslthl"> <fo:inline font-weight="bold" font-style="italic" color="#2A00FF"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> <xsl:template match='xslthl:comment' mode="xslthl"> <fo:inline font-style="italic" color="#3F5FBF"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> <xsl:template match='xslthl:tag' mode="xslthl"> <fo:inline font-weight="bold" color="#3F7F7F"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> <xsl:template match='xslthl:attribute' mode="xslthl"> <fo:inline font-weight="bold" color="#7F007F"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> <xsl:template match='xslthl:value' mode="xslthl"> <fo:inline font-weight="bold" color="#2A00FF"><xsl:apply-templates mode="xslthl"/></fo:inline> </xsl:template> </xsl:stylesheet>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,920,060,941,604,867,000
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl" version='1.0'> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/highlight.xsl"/> <xsl:import href="common.xsl"/> <!-- Only use scaling in FO --> <xsl:param name="ignore.image.scaling">1</xsl:param> <!-- Use code syntax highlighting --> <xsl:param name="highlight.source">1</xsl:param> <!-- Activate Graphics --> <xsl:param name="callout.graphics" select="1" /> <xsl:param name="callout.defaultcolumn">120</xsl:param> <xsl:param name="callout.graphics.path">images/callouts/</xsl:param> <xsl:param name="callout.graphics.extension">.png</xsl:param> <xsl:param name="table.borders.with.css" select="1"/> <xsl:param name="html.stylesheet.type">text/css</xsl:param> <xsl:param name="admonition.title.properties">text-align: left</xsl:param> <!-- Leave image paths as relative when navigating XInclude --> <xsl:param name="keep.relative.image.uris" select="1"/> <!-- Label Chapters and Sections (numbering) --> <xsl:param name="chapter.autolabel" select="1"/> <xsl:param name="section.autolabel" select="1"/> <xsl:param name="section.autolabel.max.depth" select="2"/> <xsl:param name="section.label.includes.component.label" select="1"/> <xsl:param name="table.footnote.number.format" select="'1'"/> <!-- Remove "Chapter" from the Chapter titles... --> <xsl:param name="local.l10n.xml" select="document('')"/> <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"> <l:l10n language="en"> <l:context name="title-numbered"> <l:template name="chapter" text="%n.&#160;%t"/> <l:template name="section" text="%n&#160;%t"/> </l:context> </l:l10n> </l:i18n> <!-- Syntax Highlighting --> <xsl:template match='xslthl:keyword' mode="xslthl"> <span class="hl-keyword"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:comment' mode="xslthl"> <span class="hl-comment"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:oneline-comment' mode="xslthl"> <span class="hl-comment"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:multiline-comment' mode="xslthl"> <span class="hl-multiline-comment"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:tag' mode="xslthl"> <span class="hl-tag"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:attribute' mode="xslthl"> <span class="hl-attribute"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:value' mode="xslthl"> <span class="hl-value"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <xsl:template match='xslthl:string' mode="xslthl"> <span class="hl-string"><xsl:apply-templates mode="xslthl"/></span> </xsl:template> <!-- Custom Title Page --> <xsl:template match="author" mode="titlepage.mode"> <xsl:if test="name(preceding-sibling::*[1]) = 'author'"> <xsl:text>, </xsl:text> </xsl:if> <span class="{name(.)}"> <xsl:call-template name="person.name"/> <xsl:apply-templates mode="titlepage.mode" select="./contrib"/> </span> </xsl:template> <xsl:template match="authorgroup" mode="titlepage.mode"> <div class="{name(.)}"> <h2>Authors</h2> <xsl:apply-templates mode="titlepage.mode"/> </div> </xsl:template> </xsl:stylesheet>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
2,029,779,875,179,521,800
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl" version='1.0'> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/> <xsl:import href="html.xsl"/> <xsl:param name="html.stylesheet">css/manual-multipage.css</xsl:param> <xsl:param name="chunk.section.depth">'5'</xsl:param> <xsl:param name="use.id.as.filename">'1'</xsl:param> <!-- Replace chunk-element-content from chunk-common to add firstpage class to body --> <xsl:template name="chunk-element-content"> <xsl:param name="prev"/> <xsl:param name="next"/> <xsl:param name="nav.context"/> <xsl:param name="content"> <xsl:apply-imports/> </xsl:param> <xsl:call-template name="user.preroot"/> <html> <xsl:call-template name="html.head"> <xsl:with-param name="prev" select="$prev"/> <xsl:with-param name="next" select="$next"/> </xsl:call-template> <body> <xsl:if test="count($prev) = 0"> <xsl:attribute name="class">firstpage</xsl:attribute> </xsl:if> <xsl:call-template name="body.attributes"/> <xsl:call-template name="user.header.navigation"/> <xsl:call-template name="header.navigation"> <xsl:with-param name="prev" select="$prev"/> <xsl:with-param name="next" select="$next"/> <xsl:with-param name="nav.context" select="$nav.context"/> </xsl:call-template> <xsl:call-template name="user.header.content"/> <xsl:copy-of select="$content"/> <xsl:call-template name="user.footer.content"/> <xsl:call-template name="footer.navigation"> <xsl:with-param name="prev" select="$prev"/> <xsl:with-param name="next" select="$next"/> <xsl:with-param name="nav.context" select="$nav.context"/> </xsl:call-template> <xsl:call-template name="user.footer.navigation"/> </body> </html> <xsl:value-of select="$chunk.append"/> </xsl:template> </xsl:stylesheet>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
2,029,874,123,625,817,900
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl" version='1.0'> <!-- Extensions --> <xsl:param name="use.extensions">1</xsl:param> <xsl:param name="tablecolumns.extension">0</xsl:param> <xsl:param name="callout.extensions">1</xsl:param> <!-- Graphics --> <xsl:param name="admon.graphics" select="1"/> <xsl:param name="admon.graphics.path">images/</xsl:param> <xsl:param name="admon.graphics.extension">.png</xsl:param> <!-- Table of Contents --> <xsl:param name="generate.toc"> book toc,title sect1 toc,title sect2 toc,title sect3 toc,title </xsl:param> <xsl:param name="toc.section.depth">3</xsl:param> <xsl:param name="generate.section.toc.level">2</xsl:param> </xsl:stylesheet>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
77,273,228,292,594,800
@IMPORT url("manual.css"); body.firstpage { background: url("../images/background.png") no-repeat center top; }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,136,742,331,934,944,000
@IMPORT url("manual.css"); body { background: url("../images/background.png") no-repeat center top; }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,635,146,594,949,828,000
/* code highlight CSS resemblign the Eclipse IDE default color schema @author Costin Leau */ .hl-keyword { color: #7F0055; font-weight: bold; } .hl-comment { color: #3F5F5F; font-style: italic; } .hl-multiline-comment { color: #3F5FBF; font-style: italic; } .hl-tag { color: #3F7F7F; } .hl-attribute { color: #7F007F; } .hl-value { color: #2A00FF; } .hl-string { color: #2A00FF; }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,462,759,294,770,740,000
@IMPORT url("highlight.css"); html { padding: 0pt; margin: 0pt; } body { color: #333333; margin: 15px 30px; font-family: Helvetica, Arial, Freesans, Clean, Sans-serif; line-height: 1.6; } code { font-size: 16px; } body>*:first-child { margin-top: 0 !important; } div { margin: 0pt; } hr { border: 1px solid #CCCCCC; background: #CCCCCC; } h1,h2,h3,h4,h5,h6 { color: #000000; cursor: text; font-weight: bold; margin: 20px 0 10px; padding: 0; } h1 { border-bottom: 1px solid #CCCCCC; margin: 50px 0 30px; } h1,h1 code { font-size: 32px; } h2,h2 code { font-size: 24px; } h3,h3 code { font-size: 20px; } h4,h1 code,h5,h5 code,h6,h6 code { font-size: 18px; } div.book,div.chapter,div.appendix,div.part { min-width: 300px; max-width: 1200px; margin: 0 auto; } p.releaseinfo { font-weight: bold; margin-bottom: 40px; margin-top: 40px; } div.authorgroup { line-height: 1; } p.copyright { line-height: 1; margin-bottom: -5px; } .legalnotice p { font-style: italic; font-size: 14px; line-height: 1; } div.titlepage+p,div.titlepage+p { margin-top: 0; } pre { line-height: 1.0; color: black; } a { color: #4183C4; text-decoration: none; } p { margin: 15px 0; text-align: left; } ul,ol { padding-left: 30px; } li p { margin: 0; } div.table { margin: 1em; padding: 0.5em; text-align: center; } div.table table { display: table; width: 100%; } div.table td { padding-left: 7px; padding-right: 7px; } .sidebar { font-size: 14px; line-height: 1.4; float: right; clear: both; margin: 15px 0 30px 30px; padding: 0 20px; width: 33%; background-color: #F8F8F8; border: 1px solid #CCCCCC; border-radius: 3px 3px 3px 3px; float: right; } pre.programlisting { font-size: 13px; padding: 6px 10px; background-color: #F8F8F8; border: 1px solid #CCCCCC; border-radius: 3px 3px 3px 3px; clear: both; overflow: auto; line-height: 1.2; } table { border-collapse: collapse; border-spacing: 0; border: none !important; } table tr { background-color: #FFFFFF; border-top: 1px solid #CCCCCC; border-bottom: none; } table th { font-weight: bold; background-color: #DCDCDC; } table th,table td { border: 1px solid #CCCCCC !important; padding: 6px 13px; } table tr:nth-child(2n) { background-color: #F8F8F8; } td p { margin: 0 0 15px 0; } div.table-contents td p { margin: 0; } div.important *,div.note *,div.tip *,div.warning *,div.navheader *,div.navfooter *,div.calloutlist * { border: none !important; background: none !important; } div.calloutlist p, div.calloutlist td { padding: 0; margin: 0; } div.calloutlist > table > tbody > tr > td:first-child { padding-left: 10px; width: 30px !important; } div.important,div.note,div.tip,div.warning { margin-left: 40px !important; margin-right: 20px !important; margin-top: 10px; margin-bottom: 10px; } div.toc { line-height: 1.1; } dl,dt { margin-top: 1px; margin-bottom: 0; } tbody.footnotes * { border: none !important; } div.footnote p { margin: 0; line-height: 1; } div.footnote p sup { margin-right: 6px; vertical-align: middle; } div.navheader { border-bottom: 1px solid #CCCCCC; } div.navfooter { border-top: 1px solid #CCCCCC; }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,007,509,700,860,945,000
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.astamuse</groupId> <artifactId>asta4d</artifactId> <version>1.2.1-SNAPSHOT</version> </parent> <groupId>com.astamuse</groupId> <artifactId>asta4d-sample</artifactId> <version>1.2.1-SNAPSHOT</version> <packaging>war</packaging> <name>com.astamuse.asta4d-sample</name> <description>sample of asta4d framework, shows how to use asta4d</description> <dependencies> <dependency> <groupId>com.astamuse</groupId> <artifactId>asta4d-web</artifactId> <version>${project.parent.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.0.2.Final</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.5</version> <configuration> <skip>true</skip> </configuration> </plugin> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>process-resources</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <delete dir="../asta4d-archetype-prototype/src" /> <copy todir="../asta4d-archetype-prototype/src"> <fileset dir="src" includes="**/*" /> </copy> </target> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <encoding>utf-8</encoding> <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/src</outputDirectory> <resources> <resource> <directory>src/main/java</directory> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.6</version> <configuration> <instrumentation> <excludes> <exclude>**</exclude> </excludes> </instrumentation> </configuration> </plugin> </plugins> </build> <profiles> <!-- With this profile, jetty will run during the "test" phase --> <profile> <id>jetty-run</id> <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.8.v20150217</version> <configuration> <systemProperties> <systemProperty> <name>asta4d.sample.debug</name> <value>true</value> </systemProperty> <systemProperty> <name>asta4d.sample.source_location</name> <value>${basedir}/src/main/java</value> </systemProperty> </systemProperties> <webApp> <contextPath>/</contextPath> </webApp> </configuration> <executions> <execution> <id>jetty-run</id> <phase>test</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,089,918,787,636,447,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Use ContextData annotation </afd:block> <afd:block override="content-detail"> <section> <!-- @ShowCode:showContextdataStart --> <article> <dl> <dt>User @ContextData to change variable name.</dt> <dd var="value" afd:render="ComplicatedSnippet:changeName">changeName</dd> <dt>User @ContextData to specific query scope.</dt> <dd var="value" afd:render="ComplicatedSnippet:specificScope">specificScope</dd> <dt>User convenient @QueryParam instead of @ContextData.</dt> <dd var="value" afd:render="ComplicatedSnippet:convenientAnnotation">convenient</dd> </dl> </article> <!-- @ShowCode:showContextdataEnd --> </section> <div afd:render="ShowCodeSnippet:showCode" file="/templates/contextdata.html" startMark="showContextdataStart" endMark="showContextdataEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/ComplicatedSnippet.java" startMark="showContextdataStart" endMark="showContextdataEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,129,937,595,790,526,600
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Experience some type of Renderers </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showRenderertypesStart --> <section> <article> <afd:snippet render="ComplicatedSnippet"> <ul id="childreplacer"> <li>This is dummy list.</li> <li>This is dummy list.</li> </ul> <ul id="clearnode"> <p>This is dummy text.</p> </ul> </afd:snippet> </article> </section> <!-- @ShowCode:showRenderertypesEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/renderertypes.html" startMark="showRenderertypesStart" endMark="showRenderertypesEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/ComplicatedSnippet.java" startMark="showRenderertypesStart" endMark="showRenderertypesEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,760,647,114,266,533,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> simulate a snippet side error </afd:block> <afd:block override="content-detail"> <div afd:render="SimpleSnippet:errorOccurs">dummy text</div> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-3,737,459,046,654,793,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Pass variables from outer Snippet to inner Snippet </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showPassvariablesStart --> <section> <article> <div id="outer" afd:render="ComplicatedSnippet:outer"> <div id="inner" afd:render="ComplicatedSnippet:inner"> <p id="name">name:<span>name</span></p> <p id="age">age:<span>age</span></p> <p id="currenttime">currenttime:<span>currenttime</span></p> <ul id="list"> <li>dummy list</li> </ul> </div> </div> </article> </section> <!-- @ShowCode:showPassvariablesEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/passvariables.html" startMark="showPassvariablesStart" endMark="showPassvariablesEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/ComplicatedSnippet.java" startMark="showPassvariablesStart" endMark="showPassvariablesEnd"/> </afd:block> </body> </html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="../css/common.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../css/prettify.css" type="text/css" media="all"> <script type="text/javascript" src="../js/prettify.js"></script> <title>Asta4D Sample Project</title> </head> <body onload="prettyPrint()"> <h1>.</h1> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,491,277,868,750,038,000
<html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="../css/common.css" rel="stylesheet" type="text/css" /> <title>Asta4D Sample Project</title> </head> <body> <h1>Error Page</h1> <section> <article> <p>Some error has occurred.</p> </article> </section> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,194,636,968,345,729,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Use Snippet for rendering dynamic page </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showSnippetStart --> <section> <article> <div afd:render="SimpleSnippet">dummy text</div> <afd:snippet render="SimpleSnippet:setProfile"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> </article> </section> <!--@ShowCode:showSnippetEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/snippet.html" startMark="showSnippetStart" endMark="showSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/SimpleSnippet.java" startMark="showSnippetStart" endMark="showSnippetEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,993,896,902,813,091,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Localize Messages(i18n support) </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showLocalizeStart --> <section> <article> <div class="panel panel-default"><div class="panel-body"> <!-- the inner html will be treated as default message if the key is not found in message bundle --> <afd:msg id="notexistingkey" key="sample.notexistingkey" p0="parameter works as well.">text here to be treated as default message.{0}</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- simply specify parameters on tag --> <afd:msg id="peoplecount" key="sample.peoplecount" p0="4">dummy text</afd:msg><br/> <afd:msg id="peoplecount" key="sample.peoplecount" p0="7" locale="ja_JP">dummy text</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- the parameter can be rendered by snippet too --> <afd:snippet render="ComplicatedSnippet:setMsgParam"> <afd:msg id="peoplecount" key="sample.peoplecount" p0="4">dummy text</afd:msg><br/> <afd:msg id="peoplecount" key="sample.peoplecount" p0="7" locale="ja_JP">dummy text</afd:msg><br/> </afd:snippet> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- attribute started with "@" will be treated as a key --> <afd:msg id="weatherreport" key="sample.weatherreport" @p0="sample.weatherreport.sunny">天気</afd:msg><br/> <afd:msg id="weatherreport" key="sample.weatherreport" @p0="sample.weatherreport.sunny" locale="ja_JP">天気</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- attribute started with "#" will be treated as a sub key of current key, thus sample.weatherreport.sunny will be searched --> <afd:msg id="weatherreport" key="sample.weatherreport" #p0="rain">天気</afd:msg><br/> <afd:msg id="weatherreport" key="sample.weatherreport" #p0="rain" locale="ja_JP">天気</afd:msg><br/> </div></div> <div class="panel panel-default"><div class="panel-body"> <!-- treat message as text --> <afd:msg key="sample.textUrl"></afd:msg><br/> <!-- treat message as html --> <afd:msg key="sample.htmlUrl"></afd:msg><br/> <!-- treat message as text even it begins with html: --> <afd:msg key="sample.escapedUrl"></afd:msg><br/> </div></div> </article> </section> <!-- @ShowCode:showLocalizeEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/localize.html" startMark="showLocalizeStart" endMark="showLocalizeEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/ComplicatedSnippet.java" startMark="showLocalizeStart" endMark="showLocalizeEnd"/> <div class=" panel panel-default"> <div class=" panel-heading">/message.properties</div> <div class=" panel-body"> <pre> sample.peoplecount=There are(is) {0} people in the room. sample.weatherreport=Today''s weather is {0}. sample.weatherreport.sunny=good sample.weatherreport.cloudy=not good sample.weatherreport.rain=bad sample.textUrl=Click &lt;a href="http://asta4d.sample.com/">here&lt;/a&gt; to contact us. sample.htmlUrl=html:Click &lt;a href="http://asta4d.sample.com/">here&lt;/a&gt; to contact us. sample.escapedUrl=text:html:Click &lt;a href="http://asta4d.sample.com/"&gt;here&lt;/a&gt; to contact us. </pre> </div> </div> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,554,630,871,253,897,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Manipulate attribute values </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showAttributevaluesStart --> <section> <article> <afd:snippet render="SimpleSnippet:manipulateAttrValues"> <ul> <li>set checked attribute to no button<br/> <input type="radio" id="yes" name="yesno" value="YES"/><label for="yes">YES</label> <input type="radio" id="no" name="yesno" value="NO"/><label for="no">NO</label> <li>delete disabled attribute<br/> <button type="button" id="delete" disabled="disabled">button</button> <li id="plus" class="bold italic">add "red" to class value <li id="minus" class="bold italic">remove "bold" to class value </ul> </afd:snippet> </article> </section> <!-- @ShowCode:showAttributevaluesEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/attributevalues.html" startMark="showAttributevaluesStart" endMark="showAttributevaluesEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/SimpleSnippet.java" startMark="showAttributevaluesStart" endMark="showAttributevaluesEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,650,510,990,666,075,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Asta4D Sample Project - Index </afd:block> <afd:block override="content-detail"> <div class="panel panel-info panel-usage panel-usage-simple"> <div class="panel-heading"><h2>Simple usages</h2></div> <div class="panel-body"> <ul> <li><a href="/snippet">Use Snippet for rendering dynamic page.</a></li> <li>Inject values of the variable.(/{name}/{age}) <ul> <li><a href="/var-injection/foo/25">name=foo, age=25</a></li> <li><a href="/var-injection/bar/20">name=bar, age=20</a></li> </ul> </li> <li><a href="/attributevalues">Manipulate attribute values.</a></li> <li><a href="/extend/appendchild">Template extension</a> <li><a href="/embed/main">Embed other template.</a></li> <!-- li><a href="/handler">Use Request Handler for side effects.</a></li--> <li><a href="/localize">Localize Messages(i18n support).</a></li> <li>Error handling <ul> <li><a href="/error-sample/handler404">404 exception by request handler</a></li> <li><a href="/error-sample/handler">exception occurs at the request handler</a></li> <li><a href="/error-sample/snippet">exception occurs at the snippet</a></li> </ul> </ul> </div> </div> <div class="panel panel-warning panel-usage panel-usage-complicated"> <div class="panel-heading"><h2>Complicated usages</h2></div> <div class="panel-body"> <ul> <li>Form flow <ul> <li><a href="/form?type=singlestep">Single input step</a> <li><a href="/form?type=multistep">Input, Confirm and Complete</a> <li><a href="/form?type=cascade">Cascade and array field</a> <li><a href="/form?type=multiinput">Multiple input steps</a> <li><a href="/form?type=splittedinput">Splitted input steps</a> </ul> </li> <li><a href="/renderertypes">Experience some type of Renderers.</a></li> <li><a href="/passvariables">Pass variables from outer Snippet to inner Snippet.</a></li> <li><a href="/contextdata?var=yyy">Use ContextData annotation.</a></li> </ul> </div> </div> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,277,249,337,848,403,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Inject values of the variable. </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showVariableinjectionStart --> <section> <article> <!-- the default "render" method of SimpleSnippet will be used --> <div afd:render="SimpleSnippet">title here</div> <afd:snippet render="SimpleSnippet:setProfileByVariableInjection"> <p id="name">name:<span>dummy name</span></p> <p id="age">age:<span>0</span></p> </afd:snippet> </article> </section> <!-- @ShowCode:showVariableinjectionEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showVariableinjectionStart" endMark="showVariableinjectionEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/variableinjection.html" startMark="showVariableinjectionStart" endMark="showVariableinjectionEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/SimpleSnippet.java" startMark="showVariableinjectionStart" endMark="showVariableinjectionEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
1,912,426,552,114,401,300
<html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="../css/common.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../css/prettify.css" type="text/css" media="all"> <script type="text/javascript" src="../js/prettify.js"></script> <title>Asta4D Sample Project</title> </head> <body onload="prettyPrint()"> <h1>Success Page</h1> <!--@ShowCode:showSuccessStart --> <section> <article> <p>Request Handler processing was succeed.</p> </article> </section> <!--@ShowCode:showSuccessEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showSuccessStart" endMark="showSuccessEnd"> </div> <div afd:render="ShowCodeSnippet:showCode" file="/handler/LoginHandler.java" startMark="showSuccessStart" endMark="showSuccessEnd"> </div> <div afd:render="ShowCodeSnippet:showCode" file="/templates/success.html" startMark="showSuccessStart" endMark="showSuccessEnd"> </div> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
6,157,976,197,050,141,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Embed other template </afd:block> <afd:block override="content-detail"> <!-- @ShowCode:showMainStart --> <section> <article> <ol> <p>This is main template text.</p> <afd:embed target="/templates/embed/embedded.html"/> <afd:embed target="/templates/embed/embedded_withbody.html"/> </ol> </article> </section> <!-- @ShowCode:showMainEnd --> <div afd:render="ShowCodeSnippet:showCode" file="/templates/embed/main.html" startMark="showMainStart" endMark="showMainEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/embed/embedded.html" startMark="showEmbeddedStart" endMark="showEmbeddedEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/embed/embedded_withbody.html" startMark="showEmbeddedStart" endMark="showEmbeddedEnd"/> </afd:block> </body> </html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="../../css/common.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../../css/prettify.css" type="text/css" media="all"> <script type="text/javascript" src="../../js/prettify.js"></script> <title>Asta4D Sample Project</title> </head> <body onload="prettyPrint()"> <h1>.</h1> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,401,748,563,207,971,000
<!-- @ShowCode:showEmbeddedStart --> <html> <head> <meta charset="utf-8"> </head> <body> <!-- only the contents in body will be embeded --> <p>This is embedded template text in a html file with full html structure</p> </body> </html> <!-- @ShowCode:showEmbeddedEnd -->
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,950,657,803,141,957,000
<!-- @ShowCode:showEmbeddedStart --> <p>This is embedded template text.</p> <!-- @ShowCode:showEmbeddedEnd -->
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,883,626,656,403,273,200
<html> <head></head> <body> <afd:comment> we do not extend this page from any existing common parent because we have no idea where the error occurs but we have to make sure at least this page can be shown correctly. </afd:comment> There is an error occured. Check the log. <div style="margin:30px;background-color: WhiteSmoke;"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showGlobalErrorRuleStart" endMark="showGlobalErrorRuleEnd"/> </div> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,237,836,355,803,173,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:comment> we extend this page from the common parent because this is an expected action and we know that there is no error. </afd:comment> <afd:block override="content-title"> Asta4D Sample Project - 404 </afd:block> <afd:block override="content-detail"> The target data does not exist. <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showGlobal404RuleStart" endMark="showGlobal404RuleEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,805,062,697,671,705,600
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Template extension mechanism </afd:block> <afd:block override="content-detail"> <ul class="nav nav-tabs" role="tablist" afd:render="ExtendSnippet:renderTabs"> <li id="appendchild" role="presentation"><a href="/extend/appendchild">append</a></li> <li id="insertchild" role="presentation"><a href="/extend/insertchild">insert</a></li> <li id="overridechild" role="presentation"><a href="/extend/overridechild">override</a></li> </ul> <!-- @ShowCode:showParentStart --> <section> <article> <ol> <afd:block id="block"> <li>This is parent template text.</li> </afd:block> </ol> </article> </section> <!-- @ShowCode:showParentEnd --> <afd:block id="source"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/extend/parent.html" startMark="showParentStart" endMark="showParentEnd"/> </afd:block> </afd:block> </body> </html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="../../css/common.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../../css/prettify.css" type="text/css" media="all"> <script type="text/javascript" src="../../js/prettify.js"></script> <title>Asta4D Sample Project</title> </head> <body onload="prettyPrint()"> <h1>Extend other template.</h1> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,488,918,755,540,435,000
<!-- @ShowCode:showOverridechildStart --> <afd:extension parent="/templates/extend/parent.html"> <afd:block override="block"> <li>This is child template text.</li> </afd:block> <!-- @ShowCode:showOverridechildEnd --> <afd:block append="source"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/extend/overridechild.html" startMark="showOverridechildStart" endMark="showOverridechildEnd"> </div> </afd:block> <!-- @ShowCode:showOverridechildStart --> </afd:extension> <!-- @ShowCode:showOverridechildEnd -->
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-3,956,109,609,054,999,000
<!-- @ShowCode:showInsertchildStart --> <afd:extension parent="/templates/extend/parent.html"> <afd:block insert="block"> <li>This is child template text.</li> </afd:block> <!-- @ShowCode:showInsertchildEnd --> <afd:block append="source"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/extend/insertchild.html" startMark="showInsertchildStart" endMark="showInsertchildEnd"> </div> </afd:block> <!-- @ShowCode:showInsertchildStart --> </afd:extension> <!-- @ShowCode:showInsertchildEnd -->
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,942,605,279,753,708,500
<!-- @ShowCode:showAppendchildStart --> <afd:extension parent="/templates/extend/parent.html"> <afd:block append="block"> <li>This is child template text.</li> </afd:block> <!-- @ShowCode:showAppendchildEnd --> <afd:block append="source"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/extend/appendchild.html" startMark="showAppendchildStart" endMark="showAppendchildEnd"> </div> </afd:block> </afd:extension> <!-- @ShowCode:showAppendchildEnd -->
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,428,662,335,828,676,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block append="header-resource"> <script> function saveId(v){ $("#checkedRowId").attr("value", v); } function getId(){ return document.getElementById("checkedRowId").getAttribute("value"); } function singleStepAdd(){ location.href="form/singlestep"; } function singleStepMod(){ location.href="form/singlestep?id="+getId(); } function mstepadd(){ location.href="form/multistep"; } function mstepmod(){ location.href="form/multistep?id="+getId(); } function casadd(){ location.href="form/cascade/add"; } function casmod(){ location.href="form/cascade/edit?id="+getId(); } function minpadd(){ location.href="form/multiinput/add"; } function minpmod(){ location.href="form/multiinput/edit?id="+getId(); } function spladd(){ location.href="form/splittedinput/add"; } function splmod(){ location.href="form/splittedinput/edit?id="+getId(); } </script> </afd:block> <afd:block override="content-title"> Form flow samples </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3>List</h3></div> <div class="panel-body"> <table class="table" afd:render="form.ListSnippet"> <tr> <th>&nbsp;</th> <th>name</th> <th>age</th> <th>sex</th> <th>blood</th> <th>language</th> </tr> <tr class="x-row"> <td class="x-check"><input name="_id" type=radio value="" onclick="saveId(this.value)"></td> <td class="x-name">name</td> <td class="x-age">age</td> <td class="x-sex">sex</td> <td class="x-blood">blood</td> <td class="x-language"><span>lang1</span><span afd:clear>lang2</span></td> </tr> </table> <afd:snippet render="form.ListSnippet:showTabs"> <ul id="btn-nav" class="nav nav-tabs" role="tablist"> <li id="singlestep" class="active" target-btns="single-step-btns"><a href="/form?type=singlestep">Single input step</a></li> <li id="multistep" target-btns="confirm-complete-btns"><a href="/form?type=multistep">Input, Confirm and Complete</a></li> <li id="cascade" target-btns="cascade-form-btns"><a href="/form?type=cascade">Cascade and array field</a></li> <li id="multiinput" target-btns="splitted-form-btns"><a href="/form?type=multiinput">Multiple input steps</a></li> <li id="splittedinput" target-btns="splitted-form-btns"><a href="/form?type=splittedinput">Splitted input steps</a></li> </ul> <div class="form-btns x-remove" id="singlestep"> <afd:embed target="/templates/form/singlestep/comment.html" /> <div> <button type=button class="btn btn-sm btn-default" onclick="singleStepAdd()">add</button> <button type=button class="btn btn-sm btn-default" onclick="singleStepMod()">modify</button> </div> </div> <div class="form-btns x-remove" id="multistep"> <afd:embed target="/templates/form/multistep/comment.html" /> <div> <button class="btn btn-sm btn-default" type=button onclick="mstepadd()">add</button> <button type=button class="btn btn-sm btn-default" onclick="mstepmod()">modify</button> </div> </div> <div class="form-btns x-remove" id="cascade"> <afd:embed target="/templates/form/cascade/comment.html" /> <div> <button type=button class="btn btn-sm btn-default" onclick="casadd()">add</button> <button type=button class="btn btn-sm btn-default" onclick="casmod()">modify</button> </div> </div> <div class="form-btns x-remove" id="multiinput"> <afd:embed target="/templates/form/multiinput/comment.html" /> <div> <button type=button class="btn btn-sm btn-default" onclick="minpadd()">add</button> <button type=button class="btn btn-sm btn-default" onclick="minpmod()">modify</button> </div> </div> <div class="form-btns x-remove" id="splittedinput"> <afd:embed target="/templates/form/splittedinput/comment.html" /> <div> <button type=button class="btn btn-sm btn-default" onclick="spladd()">add</button> <button type=button class="btn btn-sm btn-default" onclick="splmod()">modify</button> </div> </div> </afd:snippet> </div> </div> <input type=hidden id="checkedRowId"> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,414,454,555,189,563,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showConfirmStart --> <afd:extension parent="/templates/form/cascade/formBase.html"> <afd:block override="form-step-name">Confirm</afd:block> <afd:block override="form-btns"> <afd:embed target="/templates/form/multistep/btns-confirm.html"/> </afd:block> <!-- @ShowCode:showConfirmEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/confirm.html" startMark="showConfirmStart" endMark="showConfirmEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
8,632,206,011,042,574,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showCompleteStart --> <afd:extension parent="/templates/form/cascade/formBase.html"> <afd:block override="form-step-name">Complete</afd:block> <afd:block override="form-btns"> <afd:embed target="/templates/form/multistep/btns-complete.html"/> </afd:block> <!-- @ShowCode:showCompleteEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/complete.html" startMark="showCompleteStart" endMark="showCompleteEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-4,386,987,751,014,526,500
<html> <head> <meta charset="utf-8"> </head> <body> <ul> <li>declare two url rules for separated handlers for add and edit <li>extend from common form page for steps rather than embeding <li>cascade form <ul> <li>reuse a form POJO across different form flows <li>handle dynamic length fields(array fields) </ul> <li>use @AvailableWhenEditOnly to hide edit operation related DOMs on display mode <li>exit flow without final complete page <li>customize global message bar </ul> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
362,020,543,875,117,100
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInputStart --> <afd:extension parent="/templates/form/cascade/formBase.html"> <afd:block override="form-step-name">Input</afd:block> <afd:block override="form-btns"> <afd:embed target="/templates/form/multistep/btns-input.html"/> </afd:block> <!-- @ShowCode:showInputEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showCascadeStart" endMark="showCascadeEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/input.html" startMark="showInputStart" endMark="showInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/btns-input.html" startMark="showBtnsStart" endMark="showBtnsEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/CascadeFormSnippet.java" startMark="showCascadeFormSnippetStart" endMark="showCascadeFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/cascade/CascadeFormHandler.java" startMark="showCascadeFormHandlerStart" endMark="showCascadeFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/cascade/PersonFormIncludingCascadeForm.java" startMark="showPersonFormIncludingCascadeFormStart" endMark="showPersonFormIncludingCascadeFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/JobForm.java" startMark="showJobFormStart" endMark="showJobFormEnd"/> <h3>The following shows how to customize the global message bar</h3> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/formBase.html" startMark="showMessageBarStart" endMark="showMessageBarEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/cascade/customGlobalMessageBar.html" startMark="showMessageBarStart" endMark="showMessageBarEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,415,252,631,801,206,500
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showMessageBarStart --> <!-- The id such as "global-msg-container", "info-msg", "warn-msg", "err-msg" can be changed by Configuration. We simply use the default id. --> <div id="global-msg-container" style="width:90%;"> <ul id="info-msg"> <li class="alert alert-info" role="alert" afd:message-duplicator>info-msg-stub</li> </ul> <ul id="warn-msg"> <li class="alert alert-warning" role="alert" afd:message-duplicator>warn-msg-stub</li> </ul> <ul id="err-msg"> <li class="alert alert-danger" role="alert" afd:message-duplicator>err-msg-stub</li> </ul> </div> <!-- @ShowCode:showMessageBarEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,460,750,802,746,130,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showConfirmStart --> <afd:extension parent="/templates/form/multiinput/formBase.html"> <afd:block override="heading-block"> Confirm </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/multiinput/formPerson.html"/> <afd:embed target="/templates/form/multiinput/formJob.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="confirm"> <input type="hidden" name="step-failed" value="input-1"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-2">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">send</button> </div> </afd:block> <!-- @ShowCode:showConfirmEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/confirm.html" startMark="showConfirmStart" endMark="showConfirmEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
414,123,706,197,578,300
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="global-message"> <!-- @ShowCode:showMessageBarStart --> <afd:embed target="/templates/form/multiinput/customGlobalMessageBar.html"/> <!-- @ShowCode:showMessageBarEnd --> </afd:block> <afd:block override="content-title"> multi input form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3><afd:block id="heading-block"></afd:block></h3></div> <div class="panel-body"> <div class="block-main"> <!-- @ShowCode:showFormStart --> <section> <article> <form method="post"> <afd:block id="form-block"></afd:block> <afd:block id="form-btns"></afd:block> </form> </article> </section> <!-- @ShowCode:showFormEnd --> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/multiinput/comment.html" /> </div> </div> </div> <afd:block id="source-block"></afd:block> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,071,971,647,186,546,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showCompleteStart --> <afd:extension parent="/templates/form/multiinput/formBase.html"> <afd:block override="heading-block"> Complete </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/multiinput/formPerson.html"/> <afd:embed target="/templates/form/multiinput/formJob.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <button type="submit" name="step-exit" value="exit">return</button> </div> </afd:block> <!-- @ShowCode:showCompleteEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/complete.html" startMark="showCompleteStart" endMark="showCompleteEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,501,687,476,204,081,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showFormStart --> <afd:snippet render="form.MultiInputFormSnippet"> <table border=0 class="form-input-table"> <tr> <td>name *:</td> <td class="name"> <input name="name" type="text"/><span id="input-comment">(length &lt;=6)</span> <div><span id="name-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>age *:</td> <td class="age"> <input name="age" type="text"/><span id="input-comment">(&lt;=45)</span> <div><span id="age-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>sex *:</td> <td class="sex"> <input id="sex" name="sex" type="radio"/><label for="sex">M</label> <div><span id="sex-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>bloodtype *:</td> <td class="bloodtype"> <select id="bloodtype" name="bloodtype"> <option value="A">A</option> <option value="R" afd:clear>R</option> </select> <div><span id="bloodtype-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>language *:</td> <td class="language"> <input id="language" name="language" type="checkbox"/><label for="language">M</label> <div><span id="language-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>memo:</td> <td class="memo"> <textarea name="memo"></textarea> <div><span id="memo-err-msg" class="label label-danger"></span></div> </td> </tr> </table> <input type="hidden" id="id" name="id"> </afd:snippet> <!-- @ShowCode:showFormEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,667,664,309,377,638,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInput2Start --> <afd:extension parent="/templates/form/multiinput/formBase.html"> <afd:block override="heading-block"> Input -Job Info- </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/multiinput/formJob.html"/> <input type="hidden" id="id" name="id"> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input-2"> <input type="hidden" name="step-failed" value="input-2"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-1">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="confirm">confirm</button> </div> </afd:block> <!-- @ShowCode:showInput2End --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showMultiInputStart" endMark="showMultiInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/input-2.html" startMark="showInput2Start" endMark="showInput2End"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/formPerson.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/MultiInputFormSnippet.java" startMark="showSplittedFormSnippetStart" endMark="showSplittedFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multiinput/MultiInputFormHandler.java" startMark="showSplittedFormHandlerStart" endMark="showSplittedFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multiinput/MultiInputForm.java" startMark="showSplittedFormStart" endMark="showSplittedFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
2,332,666,333,817,557,500
<html> <head> <meta charset="utf-8"> </head> <body> <ul> <li>There are two splitted input forms for complicated input scenario</li> <li>restore values with traceMap in back/edit operation</li> <li>extra cascading form sample <ul> <li>flexible depth of cascading( Form -> Form -> Form )</li> <li>using the array in array cascading form field( Form -> Form[] -> Form[] )</li> </ul> </li> </ul> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,050,510,327,619,228,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showFormStart --> <afd:snippet render="form.MultiInputFormSnippet"> job experiences *: <a id="job-experience-add-btn" class="glyphicon glyphicon-plus" href="javascript:void(0)" onclick="$acu.addRow.apply(this)" cascade-ref-info-1="#job-experience", cascade-ref-info-2="[name=job-experience-length]", cascade-ref-info-3="[cascade-ref='job-experience-row-@']", cascade-ref-info-4="1" ></a> <div id="job-experience-err-msg" style="color: red"></div> <input type="hidden" name="job-experience-length" value="0"> <!-- The following "@" contained attributes will be rewritten to array index by default: id name cascade-ref cascade-ref-info-1, ... , cascade-ref-info-9 further rewriting can be performed by overriding the rewriteXXX methods in snippet. --> <table border=0 class="form-input-table" id="job-experience" style="margin-left: 20px"> <tr cascade-ref="job-experience-row-@"> <td> <input type="hidden" name="job-id-@"> <input type="hidden" name="job-person-id-@"> <table> <tr> <td>year:</td> <td><select name="job-year-@"> <option value="1980">1980</option> </select> </td> <td>description:</td> <td> <input type="text" name="job-description-@"> <a id="job-experience-remove-btn" href="javascript:void(0)" class="glyphicon glyphicon-minus" onclick="$acu.removeRow.apply(this)" cascade-ref-info-1="[cascade-ref=job-experience-row-@]" ></a> </td> </tr> <tr> <td>&nbsp;</td> <td id="job-position-@" colspan=3> job positions *: <a id="job-position-add-btn-@" href="javascript:void(0)" class="glyphicon glyphicon-plus" style="color:green" onclick="$acu.addRow.apply(this)" cascade-ref-info-1="#job-position-@", cascade-ref-info-2="[name=job-position-length-@]", cascade-ref-info-3="[cascade-ref='job-position-row-@-@@']", cascade-ref-info-4="2" ></a> <input type="hidden" name="job-position-length-@" value="0"> <div cascade-ref="job-position-row-@-@@" style="margin-left:20px"> <input type="hidden" name="job-position-id-@-@@"> <input type="hidden" name="job-position-job-id-@-@@"> <input type="text" name="job-position-name-@-@@"> <a id="job-position-remove-btn-@" href="javascript:void(0)" class="glyphicon glyphicon-minus" style="color:green" onclick="$acu.removeRow.apply(this)" cascade-ref-info-1="[cascade-ref=job-position-row-@-@@]" ></a> </div> </td> </tr> </table> </td> </tr> </table> </afd:snippet> <!-- @ShowCode:showFormEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
7,434,346,842,488,649,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInput1Start --> <afd:extension parent="/templates/form/multiinput/formBase.html"> <afd:block override="heading-block"> Input -Personal Info- </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/multiinput/formPerson.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input-1"> <input type="hidden" name="step-failed" value="input-1"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-1" style="visibility: hidden">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="input-2">next</button> </div> </afd:block> <!-- @ShowCode:showInput1End --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showMultiInputStart" endMark="showMultiInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/input-1.html" startMark="showInput1Start" endMark="showInput1End"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multiinput/formPerson.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/MultiInputFormSnippet.java" startMark="showSplittedFormSnippetStart" endMark="showSplittedFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multiinput/MultiInputFormHandler.java" startMark="showSplittedFormHandlerStart" endMark="showSplittedFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multiinput/MultiInputForm.java" startMark="showSplittedFormStart" endMark="showSplittedFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
6,436,637,676,276,634,000
<html> <head> <meta charset="utf-8"> </head> <body> <!-- @ShowCode:showBtnsStart --> <!-- this file can be embed by all the form html to supply a common button bar --> <input type="hidden" name="step-current" value="input"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">save</button> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <!-- @ShowCode:showBtnsEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,890,023,923,360,062,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> One step edit form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3>Input</h3></div> <div class="panel-body"> <div class="block-main"> <section> <article> <!-- @ShowCode:showInputStart --> <form method="post" afd:render="form.SingleStepFormSnippet"> <table border=0 class="form-input-table"> <tr> <td>name *:</td> <td class="name"> <input name="name" type="text"/>(length &lt;= 6) </td> </tr> <tr> <td>age *:</td> <td class="age"> <input name="age" type="text"/>(&lt;=45) </td> </tr> <tr> <td>sex *:</td> <td class="sex"> <input id="sex" name="sex" type="radio"/><label for="sex">M</label> </td> </tr> <tr> <td>bloodtype *:</td> <td class="bloodtype"> <select id="bloodtype" name="bloodtype"> <option value="A">A</option> <option value="R" afd:clear>R</option> </select> </td> </tr> <tr> <td>language *:</td> <td class="language"> <input id="language" name="language" type="checkbox"/><label for="language">M</label> </td> </tr> <tr><td>memo:</td><td class="memo"> <textarea name="memo"></textarea> </td></tr> <tr><td colspan=2> <input type="hidden" name="id"> <afd:embed target="/templates/form/singlestep/btns.html" /> </td></tr> </table> </form> <!-- @ShowCode:showInputEnd --> </article> </section> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/singlestep/comment.html" /> </div> </div> </div> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showSingleStepStart" endMark="showSingleStepEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/singlestep/edit.html" startMark="showInputStart" endMark="showInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/singlestep/btns.html" startMark="showBtnsStart" endMark="showBtnsEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/SingleStepFormSnippet.java" startMark="showSingleStepFormSnippetStart" endMark="showSingleStepFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/singlestep/SingleStepFormHandler.java" startMark="showSingleStepFormHandlerStart" endMark="showSingleStepFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/util/persondb/Person.java" startMark="showValidationAnnotationStart" endMark="showValidationAnnotationEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
1,116,847,244,126,010,500
<html> <head> <meta charset="utf-8"> </head> <body> <ul> <li>declare an url rule for a single input step form <li>define a common button template file for all the form pages <li>render option data for select, radio and checkbo by snippet <li>request handler <ul> <li>form initialization <li>update form data to database <li>output update result message to default global message bar </ul> <li>validation <ul> <li>annotate form field on form POJO <ul> <li>extend from the entity POJO <li>customize field name by nameLable of form field annotation </ul> <li>annotate bean validation on entity POJO <li>use default validation message generation mechanism <li>output validation messages to default global message bar </ul> </ul> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
3,523,712,406,935,731,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showConfirmStart --> <afd:extension parent="/templates/form/splittedinput/formBase.html"> <afd:block override="heading-block"> Confirm </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/splittedinput/formPerson.html"/> <afd:embed target="/templates/form/splittedinput/formJob.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="confirm"> <input type="hidden" name="step-failed" value="input-1"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-3">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">send</button> </div> </afd:block> <!-- @ShowCode:showConfirmEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/confirm.html" startMark="showConfirmStart" endMark="showConfirmEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-3,904,945,325,932,354,600
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="global-message"> <!-- @ShowCode:showMessageBarStart --> <afd:embed target="/templates/form/splittedinput/customGlobalMessageBar.html"/> <!-- @ShowCode:showMessageBarEnd --> </afd:block> <afd:block override="content-title"> Splitted form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3><afd:block id="heading-block"></afd:block></h3></div> <div class="panel-body"> <div class="block-main"> <!-- @ShowCode:showFormStart --> <section> <article> <form method="post"> <afd:block id="form-block"></afd:block> <afd:block id="form-btns"></afd:block> </form> </article> </section> <!-- @ShowCode:showFormEnd --> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/splittedinput/comment.html" /> </div> </div> </div> <afd:block id="source-block"></afd:block> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-8,795,859,065,239,602,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInput3Start --> <afd:extension parent="/templates/form/splittedinput/formBase.html"> <afd:block override="heading-block"> Input -Job Info- </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/splittedinput/formJob.html"/> <input type="hidden" id="id" name="id"> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input-3"> <input type="hidden" name="step-failed" value="input-3"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-2">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="confirm">confirm</button> </div> </afd:block> <!-- @ShowCode:showInput3End --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showSplittedInputStart" endMark="showSplittedInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/input-3.html" startMark="showInput3Start" endMark="showInput3End"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formPerson.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/SplittedInputFormSnippet.java" startMark="showSplittedFormSnippetStart" endMark="showSplittedFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputFormHandler.java" startMark="showSplittedFormHandlerStart" endMark="showSplittedFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputForm.java" startMark="showSplittedFormStart" endMark="showSplittedFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-5,949,194,734,374,908,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showCompleteStart --> <afd:extension parent="/templates/form/splittedinput/formBase.html"> <afd:block override="heading-block"> Complete </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/splittedinput/formPerson.html"/> <afd:embed target="/templates/form/splittedinput/formJob.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <button type="submit" name="step-exit" value="exit">return</button> </div> </afd:block> <!-- @ShowCode:showCompleteEnd --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/complete.html" startMark="showCompleteStart" endMark="showCompleteEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,230,891,762,181,067,300
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showFormStart --> <afd:snippet render="form.SplittedInputFormSnippet"> <table border=0 class="form-input-table"> <tr id="name-container"> <td>name *:</td> <td class="name"> <input name="name" type="text"/><span id="input-comment">(length &lt;=6)</span> </td> </tr> <tr id="age-container"> <td>age *:</td> <td class="age"> <input name="age" type="text"/><span id="input-comment">(&lt;=45)</span> </td> </tr> <tr id="sex-container"> <td>sex *:</td> <td class="sex"> <input id="sex" name="sex" type="radio"/><label for="sex">M</label> </td> </tr> <tr id="bloodtype-container"> <td>bloodtype *:</td> <td class="bloodtype"> <select id="bloodtype" name="bloodtype"> <option value="A">A</option> <option value="R" afd:clear>R</option> </select> </td> </tr> <tr id="language-container"> <td>language *:</td> <td class="language"> <input id="language" name="language" type="checkbox"/><label for="language">M</label> </td> </tr> <tr id="memo-container"> <td>memo:</td> <td class="memo"> <textarea name="memo"></textarea> </td> </tr> </table> <input type="hidden" id="id" name="id"> </afd:snippet> <!-- @ShowCode:showFormEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-9,215,587,560,153,304,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInput2Start --> <afd:extension parent="/templates/form/splittedinput/formBase.html"> <afd:block override="heading-block"> Input -Personal Info- </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/splittedinput/formPerson.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input-2"> <input type="hidden" name="step-failed" value="input-2"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-1">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="input-3">next</button> </div> </afd:block> <!-- @ShowCode:showInput2End --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showSplittedInputStart" endMark="showSplittedInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/input-2.html" startMark="showInput2Start" endMark="showInput2End"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formPerson.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/SplittedInputFormSnippet.java" startMark="showSplittedFormSnippetStart" endMark="showSplittedFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputFormHandler.java" startMark="showSplittedFormHandlerStart" endMark="showSplittedFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputForm.java" startMark="showSplittedFormStart" endMark="showSplittedFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,622,621,382,063,004,000
<html> <head> <meta charset="utf-8"> </head> <body> <ul> <li>There are three input steps. <li>Utilizing ExcludingFieldRetrievableForm mechanism. <ul> <li>The first and second input step share the same form class (split single form into multiple input steps) <li>The first and second input step share the same html snippet for page rendering. </ul> <li>Making use of StepRepresentableForm to specify form rendering target rather the whole form instance itself. <li>Using StepAwaredValidatableForm and StepAwaredValidationTarget to annotate validation target rather than the form instance itself. </ul> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-2,019,973,664,405,187,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showFormStart --> <afd:snippet render="form.SplittedInputFormSnippet"> job experiences *: <a id="job-experience-add-btn" class="glyphicon glyphicon-plus" href="javascript:void(0)" onclick="$acu.addRow.apply(this)" cascade-ref-info-1="#job-experience", cascade-ref-info-2="[name=job-experience-length]", cascade-ref-info-3="[cascade-ref='job-experience-row-@']", cascade-ref-info-4="1" ></a> <div id="job-experience-err-msg" style="color: red"></div> <input type="hidden" name="job-experience-length" value="0"> <!-- The following "@" contained attributes will be rewritten to array index by default: id name cascade-ref cascade-ref-info-1, ... , cascade-ref-info-9 further rewriting can be performed by overriding the rewriteXXX methods in snippet. --> <table border=0 class="form-input-table" id="job-experience" style="margin-left: 20px"> <tr cascade-ref="job-experience-row-@"> <td> <input type="hidden" name="job-id-@"> <input type="hidden" name="job-person-id-@"> <table> <tr> <td>year:</td> <td><select name="job-year-@"> <option value="1980">1980</option> </select> </td> <td>description:</td> <td> <input type="text" name="job-description-@"> <a id="job-experience-remove-btn" href="javascript:void(0)" class="glyphicon glyphicon-minus" onclick="$acu.removeRow.apply(this)" cascade-ref-info-1="[cascade-ref=job-experience-row-@]" ></a> </td> </tr> <tr> <td>&nbsp;</td> <td id="job-position-@" colspan=3> job positions *: <a id="job-position-add-btn-@" href="javascript:void(0)" class="glyphicon glyphicon-plus" style="color:green" onclick="$acu.addRow.apply(this)" cascade-ref-info-1="#job-position-@", cascade-ref-info-2="[name=job-position-length-@]", cascade-ref-info-3="[cascade-ref='job-position-row-@-@@']", cascade-ref-info-4="2" ></a> <input type="hidden" name="job-position-length-@" value="0"> <div cascade-ref="job-position-row-@-@@" style="margin-left:20px"> <input type="hidden" name="job-position-id-@-@@"> <input type="hidden" name="job-position-job-id-@-@@"> <input type="text" name="job-position-name-@-@@"> <a id="job-position-remove-btn-@" href="javascript:void(0)" class="glyphicon glyphicon-minus" style="color:green" onclick="$acu.removeRow.apply(this)" cascade-ref-info-1="[cascade-ref=job-position-row-@-@@]" ></a> </div> </td> </tr> </table> </td> </tr> </table> </afd:snippet> <!-- @ShowCode:showFormEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,897,918,191,237,018,000
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showInput1Start --> <afd:extension parent="/templates/form/splittedinput/formBase.html"> <afd:block override="heading-block"> Input -Personal Info- </afd:block> <afd:block override="form-block"> <afd:embed target="/templates/form/splittedinput/formPerson.html"/> </afd:block> <afd:block override="form-btns"> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input-1"> <input type="hidden" name="step-failed" value="input-1"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input-1" style="visibility: hidden">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="input-2">next</button> </div> </afd:block> <!-- @ShowCode:showInput1End --> <afd:block append="source-block"> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showSplittedInputStart" endMark="showSplittedInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formBase.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/input-1.html" startMark="showInput1Start" endMark="showInput1End"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/splittedinput/formPerson.html" startMark="showFormStart" endMark="showFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/SplittedInputFormSnippet.java" startMark="showSplittedFormSnippetStart" endMark="showSplittedFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputFormHandler.java" startMark="showSplittedFormHandlerStart" endMark="showSplittedFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/splittedinput/SplittedInputForm.java" startMark="showSplittedFormStart" endMark="showSplittedFormEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/PersonForm.java" startMark="showPersonFormStart" endMark="showPersonFormEnd"/> </afd:block> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,517,195,566,274,310,000
<html> <head> <meta charset="utf-8"> </head> <body> <!-- @ShowCode:showBtnsStart --> <!-- this file can be embed by all the form html to supply a common button bar --> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="input"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input" style="visibility: hidden;">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="confirm">confirm</button> </div> <!-- @ShowCode:showBtnsEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,479,077,862,609,047
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Multiple steps form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3>Confirm</h3></div> <div class="panel-body"> <div class="block-main"> <!-- @ShowCode:showConfirmStart --> <section> <article> <p>Are you sure you have the correct?</p> <form method="post"> <afd:embed target="/templates/form/multistep/formContent.html"/> <afd:embed target="/templates/form/multistep/btns-confirm.html"/> </form> </article> </section> <!-- @ShowCode:showConfirmEnd --> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/multistep/comment.html" /> </div> </div> </div> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/confirm.html" startMark="showConfirmStart" endMark="showConfirmEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/btns-confirm.html" startMark="showBtnsStart" endMark="showBtnsEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multistep/MultiStepFormHandler.java" startMark="showMultiStepFormHandlerStart" endMark="showMultiStepFormHandlerEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-6,459,997,056,493,887,000
<html> <head> <meta charset="utf-8"> </head> <body> <!-- @ShowCode:showBtnsStart --> <!-- this file can be embed by all the form html to supply a common button bar --> <div class="form-btn-bar"> <input type="hidden" name="step-current" value="confirm"> <input type="hidden" name="step-failed" value="input"> <button type="submit" name="step-exit" class="btn btn-sm btn-default" value="exit">cancel</button> <button type="submit" name="step-back" class="btn btn-sm btn-default" value="input">back</button> <button type="submit" name="step-success" class="btn btn-sm btn-default" value="complete">send</button> </div> <!-- @ShowCode:showBtnsEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
580,150,233,660,336,400
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Multiple steps form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3>Complete</h3></div> <div class="panel-body"> <div class="block-main"> <!-- @ShowCode:showCompleteStart --> <section> <article> <p>Input flow completed.</p> <form method="post"> <table border=0 afd:render="form.MultiStepFormSnippet"> <!-- form field display tag with id: xxx-display --> <tr><td>name:</td><td class="name"><span id="name-display"></span></td></tr> <tr><td>age:</td><td class="age"><span id="age-display"></span></tr> <tr><td>sex:</td><td class="sex"><span id="sex-display"></span></tr> <tr><td>bloodtype:</td><td class="bloodtype"><span id="bloodtype-display"></span></td></tr> <tr><td>language:</td><td class="language"><span id="language-display"></span></td></tr> <tr><td>memo:</td><td class="memo"><pre id="memo-display" class="form-field-pre"></pre></td></tr> </table> <div class="alert alert-success x-success-msg" role="alert"></div> <afd:embed target="/templates/form/multistep/btns-complete.html"/> </form> </article> </section> <!-- @ShowCode:showCompleteEnd --> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/multistep/comment.html" /> </div> </div> </div> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/complete.html" startMark="showCompleteStart" endMark="showCompleteEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/btns-complete.html" startMark="showBtnsStart" endMark="showBtnsEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-7,453,415,298,400,450,000
<html> <head> <meta charset="utf-8"> </head> <body> <ul> <li>declare an url rule for a form process with three steps: input, confirm and complete. <li>share form html definition between step pages by embedding <li>use static option data embed in html file rather than rendering by snippet <li>form data display mode <ul> <li>automatically generated display DOM at confirm page <li>custom predefined display DOM at complete page </ul> <li>define a common parent class to configure the common actions of form flow process <li>customized validation message generation <ul> <li>customized validation message DOM in html <li>specify message by form field annotation <li>extend TypeUnMatchValidator(retrieve message from resource bundle) <li>extend JsrValueValidator and customized bean validation initialization(custom message file) </ul> <li>output update success message to a specified DOM rather than the global message bar </ul> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-3,083,448,132,335,491,000
<html> <head> <meta charset="utf-8" /> </head> <body> <afd:extension parent="/layout/common.html"> <afd:block override="content-title"> Multiple steps form </afd:block> <afd:block override="content-detail"> <div class="panel panel-warning"> <div class="panel-heading"><h3>Input</h3></div> <div class="panel-body"> <div class="block-main"> <!-- @ShowCode:showInputStart --> <section> <article> <form method="post"> <afd:embed target="/templates/form/multistep/formContent.html"/> <afd:embed target="/templates/form/multistep/btns-input.html"/> </form> </article> </section> <!-- @ShowCode:showInputEnd --> </div> <div class="block-side-comment"> <afd:embed target="/templates/form/multistep/comment.html" /> </div> </div> </div> <div afd:render="ShowCodeSnippet:showCode" file="/UrlRules.java" startMark="showMultiStepStart" endMark="showMultiStepEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/input.html" startMark="showInputStart" endMark="showInputEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/formContent.html" startMark="showFormContentStart" endMark="showFormContentEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/templates/form/multistep/btns-input.html" startMark="showBtnsStart" endMark="showBtnsEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/MultiStepFormSnippet.java" startMark="showMultiStepFormSnippetStart" endMark="showMultiStepFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multistep/MultiStepFormHandler.java" startMark="showMultiStepFormHandlerStart" endMark="showMultiStepFormHandlerEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/multistep/PersonFormForMultiStep.java" startMark="showAnnotatedMessageStart" endMark="showAnnotatedMessageEnd"/> <h3>The following shows how to configure the common actions by a common parent class</h3> <div afd:render="ShowCodeSnippet:showCode" file="/snippet/form/common/Asta4DSamplePrjCommonFormSnippet.java" startMark="showCommonFormSnippetStart" endMark="showCommonFormSnippetEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/common/Asta4DSamplePrjCommonFormHandler.java" startMark="showCommonFormHandlerStart" endMark="showCommonFormHandlerEnd"/> <h3>The following shows how to customize validation message generation</h3> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/common/SamplePrjTypeUnMatchValidator.java" startMark="showSamplePrjTypeUnMatchValidatorStart" endMark="showSamplePrjTypeUnMatchValidatorEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/common/SamplePrjValueValidator.java" startMark="showSamplePrjValueValidatorStart" endMark="showSamplePrjValueValidatorEnd"/> <div afd:render="ShowCodeSnippet:showCode" file="/handler/form/common/SamplePrjCommonValidatoinMessageLogics.java" startMark="showCreateAnnotatedMessageStart" endMark="showCreateAnnotatedMessageEnd"/> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
-1,464,918,395,812,360,200
<html> <head> <meta charset="utf-8" /> </head> <body> <!-- @ShowCode:showFormContentStart --> <!-- this file can be shared across all the step pages --> <afd:snippet render="form.MultiStepFormSnippet"> <table border=0 class="form-input-table"> <tr> <td>name *:<br>(length &lt;= 6)</td> <td class="name"> <input name="name" type="text"/> <!-- custom error message tag(default id as xxx-err-msg) --> <div><span id="name-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>age *:<br>(&lt;= 45)</td> <td class="age"> <input name="age" type="text"/> <!-- custom error message tag(default id as xxx-err-msg) --> <div><span id="age-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>sex *:</td> <td class="sex"> <!-- static option data in html --> <input id="sex-m" name="sex" type="radio" value="Male"/><label for="sex-m">Male</label> <input id="sex-f" name="sex" type="radio" value="Female"/><label for="sex-f">Female</label> <div><span id="sex-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>bloodtype *:</td> <td class="bloodtype"> <select id="bloodtype" name="bloodtype"> <!-- static option data in html --> <option value="">&nbsp;</option> <option value="A">A</option> <option value="B">B</option> <option value="O">O</option> <option value="AB">AB</option> </select> <div><span id="bloodtype-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>language *:</td> <td class="language"> <!-- static option data in html --> <input id="language-e" name="language" type="checkbox" value="English"/><label for="language-e">English</label> <input id="language-j" name="language" type="checkbox" value="Japanese"/><label for="language-j">Japanese</label> <input id="language-z" name="language" type="checkbox" value="Chinese"/><label for="language-z">Chinese</label> <div><span id="language-err-msg" class="label label-danger"></span></div> </td> </tr> <tr> <td>memo:</td> <td class="memo"> <textarea name="memo"></textarea> </td> </tr> </table> <input type="hidden" name="id"> </afd:snippet> <!-- @ShowCode:showFormContentEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
2,206,811,635,534,621,200
<html> <head> <meta charset="utf-8"> </head> <body> <!-- @ShowCode:showBtnsStart --> <!-- this file can be embed by all the form html to supply a common button bar --> <div class="form-btn-bar"> <button type="submit" name="step-exit" value="exit">return</button> </div> <!-- @ShowCode:showBtnsEnd --> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
5,069,746,892,375,910,000
<html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <afd:block id="header-common"> </afd:block> <afd:block id="header-resource"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <link type="text/css" rel="stylesheet" href="/css/common.css" /> <link type="text/css" rel="stylesheet" href="/css/prettify.css" /> <script type="text/javascript" src="/js/prettify.js"></script> </afd:block> <afd:block id="header-title"> <title>Asta4D Sample Project</title> </afd:block> </head> <body onload="prettyPrint()"> <afd:block id="content"> </afd:block> <afd:block id="footer-resource"> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> </afd:block> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
7,074,605,282,280,500,000
<html> <head> <body> <afd:extension parent="/layout/baselayout.html"> <afd:block override="content"> <div id="content-container"> <afd:block id="global-message"></afd:block> <ul class="nav nav-pills"> <li class="active"><a href="/">TOP</a></li> </ul> <h1> <afd:block id="content-title"></afd:block> </h1> <div> <afd:block id="content-detail"></afd:block> </div> </afd:block> </div> </afd:extension> </body> </html>
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
4,639,779,822,744,109,000
/* Pretty printing styles. Used with prettify.js. */ /* SPAN elements with the classes below are added by prettyprint. */ .pln { color: #000 } /* plain text */ @media screen { .str { color: #080 } /* string content */ .kwd { color: #008 } /* a keyword */ .com { color: #800 } /* a comment */ .typ { color: #606 } /* a type name */ .lit { color: #066 } /* a literal value */ /* punctuation, lisp open bracket, lisp close bracket */ .pun, .opn, .clo { color: #660 } .tag { color: #008 } /* a markup tag name */ .atn { color: #606 } /* a markup attribute name */ .atv { color: #080 } /* a markup attribute value */ .dec, .var { color: #606 } /* a declaration; a variable name */ .fun { color: red } /* a function name */ } /* Use higher contrast and text-weight for printable form. */ @media print, projection { .str { color: #060 } .kwd { color: #006; font-weight: bold } .com { color: #600; font-style: italic } .typ { color: #404; font-weight: bold } .lit { color: #044 } .pun, .opn, .clo { color: #440 } .tag { color: #006; font-weight: bold } .atn { color: #404 } .atv { color: #060 } } /* Put a border around prettyprinted code snippets. */ pre.prettyprint { padding: 2px; border: 1px solid #888 } /* Specify class=linenums on a pre to get line numbering */ ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ li.L0, li.L1, li.L2, li.L3, li.L5, li.L6, li.L7, li.L8 { list-style-type: none } /* Alternate shading for lines */ li.L1, li.L3, li.L5, li.L7, li.L9 { background: #eee }
astamuse/asta4d
162
Java
org.eclipse.core.resources.prefs
text/plain
3,126,647,967,873,381,400