impressum  •   email  •   sitemap


Get Firefox!
Sie sind hier: HomeDocumentationpsp

PSP - PHP Server Pages

PSP is a template engine, which is used for the views in phpinchains. The return value of an action method is used to identify the PSP page called after the action is completed.

A PSP is an HTML document or fragment. To define control structures and to call functions custom tags are used. They are used to reduce the number of scriptlets in a page (a scriptlet is PHP code embeded in HTML code: <?php ... ?>).

Example:
<html>
<body>
<c:if test="${var == 'test'}">
Heise
</c:if>
</body>
</html>
The c:if tag is an example for a custom tag. The expression in ${} is an example for an Expression Language (EL) expression. EL is a language which supports several operators for numbers and strings as well as boolean operators. In most cases these two tools are sufficient for all tasks. If the functionality of the existing tags is not enough, one can easily write his own custom tags.

Existing custom tags:

Control structures and core functionality
c:if, c:elseif, c:else - conditional execution
c:foreach - repetition
c:set - assigning a value to a variable
c:out - output with escaped characters
c:url, c:param, c:anchor - action urls
c:include - include PSP fragments
c:execute, c:actionparam - call actions from within a PSP

Formating and Localization
fmt:setLocale - setting the locale, especially for bundles
fmt:loadBundle - load a message bundle for usage
fmt:message, fmt:errorMessage - display bundle messages and bundle error messages

HTML Forms
h:form - equivalent of a HTML form; direct targeting of a action dispatcher action; validation
h:hidden - HTML hidden field
h:input - HTML input field; validation and error style
h:textarea - HTML textarea field; validation and error style
h:selectBox - HTML selectbox; easier generation from array; validation and error style

Extended
xt:synctokenhidden - easy usage of synchronizer token in forms
xt:synctokenparam - easy usage of synchronizer token in urls

AJAX
ajax:dojo - inclusion of the dojo framework
ajax:require - loading of dojo packages
ajax:function - remote call of an action
ajax:form - ajax replacement for h:form
ajax:cron - periodical invocation of javascript code
ajax:comboBox - a combo box widget which gets actualized via ajax calls

Existing EL expressions and operators

bool ? expr : expr - conditional operator
+, -, *, /, % - arithmetic operators
==, !=, >=, <=, >, <, !, &&, &, |, || - boolean operators
var->field - array and actionform operator (e.g. var->field instead of var['field']; var->field1->field2 ...)
var[index] - array expression
'string' - string expression
. - concat expression
fn:func - function call operator (every php function can be called e.g. fn:var_dump(var))

Features

Custom tags - programm your own tags
Tag overwriting - use standard html tags such as 'form' and let the template engine treat them like h:form or ajax:form by using 'pspc' attribute (e.g. <form pspc="h:form" action="class::method">)
Internationalization - write language bundles alike JSTL (Java Standard Tag Library)
Validation - easy to use validation; write the validation code where it belongs: in the form element tag which needs to be validated


 
copyright © 2006 synflag online agentur -- letzte änderung: 19.12.2006