Templates of Aphrodite
1.Window
The window tag is used at the topmost level of an aphrodite document to denote the start of a new HTML page. The XSL code automatically imports all the required CSS stylesheets and Javascript libraries. Hence, there can only be one of these in a document.
Attributes
sample code
class myapp(App):
def __init__(self):
self.aphrodite = aphrodite.Aphrodite('myapp')
def index(self):
x="<window >Insert more Aphrodite code here...</window>"
self.aphrodite.document = x
return self.aphrodite
index.exposed = True
use case
<window>
<center>
<label style="color:#ffffff;">
Hello world
</label>
</center>
</window>
output
2.Image (supported in platform version 1.1)
Image tag can be used where we intend to display an image. Image tag supports two types of images:
Attributes
sample code
<image id='myimage' src='/image/resources/del.gif' class='myclass' onclick='myfunc()' title='Delete' />
<image id='myimage' src='/image/resources/brainwave.gif' href='http://www.brw.com' caption='Brainwave Applications' />
use case
<window> <center> <box style="width:500px;"> <image id='myimage1' src='/resources/img/bucket.png' tooltip='Glass' /> </box> <box style="width:500px;"> <image id='myimage2' href='http://www.brainwavelive.com/' src='/resources/img/search128.png' title='Search' caption="Search"/> </box> </center> </window>
output
NOTE: In this case we have used two images. The first one is a simple image whereas the second one has a caption below it and is also hyperlinked to http://www.brainwavelive.com/.
3.Ajaxform (supported in platform version 1.1)
The ajaxform template is used to create an html form with enhanced features.The ajaxform tag supports the following attributes.
Attributes
sample code
<ajaxform id="exampleform" url="/test/ajaxformexample" method="post" update="aliases" position="bottom"> <textinput id="newalias" type="text" /> <button image="add" submit="exampleform" url="/test/ajaxformexample" title="Add a new Alias"/> </ajaxform>
use case
<box id='mybox' name='mybox' style="width:500px;" align="center"><br/> <ajaxform id="exampleform" url="/test/ajaxformexample" method="post" update="aliases" position="bottom"> <textinput id="newalias" type="text" /> <button image="add" submit="exampleform" url="/test/ajaxformexample" /> </ajaxform> <box id="aliases" title='Output'> </box> </box>
output
This is an ajaxform with a textbox and a button. We also have an output area. Whenever we type in something in the textbox and click the button the value is passed to the server via ajax and that value is displayed back in the output area.
This is the output. We have typed in "This is a test" and the value is displayed in the output area after being sent to the server and fetched back from it via ajax.
4.Button (supported in platform version 1.1)
The button template is used to define custom buttons (with images) in applications.
Attributes
sample code
<button image="add" submit="add-alias-form" url="/edit/add_alias/" title="Add a new Alias"/> <button image='/edit/resources/images/unlocked.gif' update="div1" url='/edit/protect/' title="Protect This"/>
use case
<box id='mybox' name='mybox' style="width:500px;"><br/> <label>This is a simple button :</label> <button image='/resources/skins/default/images/help.jpg' title="Help"/><br/><br/> <ajaxform id="exampleform" url="/test/ajaxformexample" method="post" update="aliases" position="bottom"> <textinput id="newalias" type="text" /> <button image="add" submit="exampleform" url="/test/ajaxformexample" title="Add a new Alias"/> </ajaxform> <box id="aliases" title='Output'> </box> </box>
output
NOTE: The first one (with a question mark) is a simple button with an image. The second one (addition sign) is used to submit data to the server and the data fetched from the server is displayed in the output area.
5.Box
The box is a generic container to hold all other kinds of information.
Attributes
sample code
<box id='mybox' name='mybox' align="center" title="Brainwave">This is a box.</box>
use case
<window> <box id='mybox' name='mybox' align='center' title='Brainwave' style="width:500px;"> This is my box. </box> </window>
output
6.Tabs (supported in platform version 1.1)
The tabs template is the main element of the tab control which defines the Javascript function for creating the tab based navigational structure.
Attributes
7.Tab (supported in platform version 1.1)
The tab template is the standard tab for navigation.
Attributes
8.Tabcontent (supported in platform version 1.1)
The tabcontent is the main tab page area. It contains all the containers (with ids corresponding to those specified in the tab template) which correspond to each 'tabs" in "tab" template. It must contain the SAME number of containers as there are "tabs" in the "tab" template.
sample code
<tabs id="Mytab"> <tab active="true" target="tabBox1">Tab1</tab> <tab target="tabBox2">Tab2</tab> <tabcontent> <div id ="tabBox1">here is the content for tab1</div> <div id ="tabBox2">here is the content for tab2</div> </tabcontent> </tabs>
use case
<center> <box id='mybox' name='mybox' style="width:500px;"> <tabs id="Mytab"> <tab active="true" target="tabBox1">Tab1</tab> <tab target="tabBox2">Tab2</tab> <tabcontent> <div id ="tabBox1" style="height:200px;"> <image id='myimage1' src='/resources/img/bucket.png' tooltip='Glass' caption="Glass"/> </div> <div id ="tabBox2" style="height:200px;"> <image id='myimage2' src='/resources/img/search128.png' tooltip='Search' caption="Search"/> </div> </tabcontent> </tabs> </box> </center>
output
Aphrodite Widget Library
The Aphrodite Widget library is a toolkit of UI components, which can be used to create a rich AJAX based web interface. Widgets are different from other Aphrodite UI controls in that they all implement the Widget API, can be submitted as part of a form and support WidgiCalc (a spreadsheet style formula engine for UI widgets).
Using widgets in your application:
9.Textbox (supported in platform version 1.1)
Creates a textbox widget. Used for entering single or multi line text or passwords.
Attributes
sample code
<textbox id='v' required='true' value=This is a textbox widget' onblur='myfunc1()' onchange='myfunc2()'/>
use case
<box id='mybox' name='mybox' style="width:500px;" align="center"><br/> <label>Multi line :</label><textbox id='text1' multiline="true" required='true' value='Attribute Value' /><br/><br/> <label>Single line :</label><textbox id='text2' required='true' value='Attribute Value' /> </box>
output
10.Datebox (supported in platform version 1.1)
Creates a datebox widget. Used for entering dates. Comes with a popup calendar to assist in graphical selection of dates and a text-parser for parsing user text into dates.
Attributes
sample code
<datebox id='v' required='true' format='dd/mm/yyyy' />
use case
<box id='mybox' name='mybox' style="width:500px;" align="center"><br/>
<table>
<tr>
<td><label style="font: 14px verdana ;color:#676767;font-weight:bold;">Date: </label></td>
<td><datebox id='v' format='mm/dd/yyyy' /></td>
</tr>
</table>
</box>
output
11.Imagelistbox (supported in platform version 1.1)
The ImageBox Widget is a matrix layout of ImageCell Widgets. Each ImageCell widget has an image, a name and an optional description. The ImageBox widget lays them all out in a matrix and provides graphical selection and navigation possible.
Attributes
sample code
<imagelistbox id="myimagelist" draggable="true" selectable="false"/>
WidgiCalc
WidgiCalc is a simple, rich yet extremely powerful framework for doing spreadsheet style formula calculations for widgets. We all know that a cell in a spreadsheet can have a formula, which causes its value to depend on other cells and change automatically as other cells are modified.
Similarly the WidgiCalc framework empowers widgets to have formulas, which cause their value to change automatically as other widgets on the page are manipulated.
First, a naming scheme is required. Since Widgets are not laid out in a two dimensional table, the spreadsheet style naming (A1, B4 etc.) will not do. Hence, all widgets have ids or names, which must be unique on the page. These names are used to access widgets and their values.
The syntax to access a widget object is as follows:
$W('mywidget') This returns a reference to the widget named "mywidget".
The syntax to access a widget value is as follows:
$w('mywidget') This returns the value of the "mywidget" widget.
This syntax must be used in formulas instead of the typical B1, $B4, $B$5 style syntax.
For example, the sample formula to add the values of two widgets (mywidget1 and mywidget2) is: =$w('mywidget1) + $w('mywidget2')
For example, the sample formula to add the values of two widgets (mywidget1 and mywidget2) is:
The supported formulae are documented below:
All formulae are defined in "resources/js/formula.js". Hence, it is simple to extend the library with your custom functions.
View Complete Brainwave API list