title

FreeMarker widgets for information input

@edit.form

Displays a form to edit an object. In combination with the macros below like @edit.field, @edit.string, @edit.text, @edit.hidden ... it is pretty smart and powerful macro and virtually always used in the admin pages of Tiny Marbles CMS to create, save or update objects. It is prepared for the usage of Ajax.

Parameters of @edit.form:

id (optional, default empty)
id of the form. name (optional, default parameter id)
name of the form. If empty, the parameter 'id' is used. formAction (optional, default empty)
the url value for the form action. title (optional, default empty)
a title for the form. If provided, text is shown inside an <h2> tag. method (optional, default 'post')
the form submission method, as described in HTML specification. onSubmit (optional, default empty)
JavaScript code to be executed upon submit. Here you can place the Ajax call if needed. target (optional, default empty)
the target. enctype (optional, default 'application/x-www-form-urlencoded')
encryption type. enableToken (optional boolean, default 'true')
creates a token for preventing double submission (used with Struts). cssClass (optional, default empty)
a CSS class used for the <div> element which frames the form.

Form confirmation: Some actions require a special confirmation token to prevent hacking scripts and <img> calls. The macro tests if a confirmation id is required and generates a hidden field called confirmationId for it.

Example for @edit.form:

<@edit.form id="updateUser" formAction="${base}/admin/user/update.action">
   <@edit.hidden name="user.id" value=user.id?c />
   <@edit.string name="user.name" size="40" required=true />
   <@edit.password name="user.password" size="40" />
   <@edit.controls>
      <@edit.button label=action.getText("control.User.submit") />
   </@edit.controls>
</@edit.form>

 

@edit.field

Shows a fieldset displaying a label and a property of an object. It can only be used inside a form. Macros like @edit.string, @edit.text, @edit.hidden or @edit.password are using it internally. The property of the object is taken from the nested content of the calling macro. For example: @edit.string calls internally @edit.field and in this case the property is shown as <input type="text" ... />. The macro is automatically adding field errors that the validation of the Struts action generated.

Parameters of @edit.form:

name (required)
the property name for this field. required (boolean, required)
if true, will style the field with a CSS class "required_field". label (optional, default empty)
the label for the property. showErrorAsLabel (optional boolean, default 'false')
Default: errors are shown below the property field. If set to 'true', errors are shown
as labels.
cssClass (optional, default empty)
a CSS class used for the <fieldset> element which frames the label and fields.

 

@edit.string

Shows an <input type="text" /> element to edit a property of an object. It can only be used inside a form. Internally it calls the macro @edit.field and displays the input element with a label framed by a fieldset. Field errors are automatically added that the validation of the Struts action generated.

Parameters of @edit.string:

name (required)
the property name for this field. id (optional, default empty)
the id for the input field. value (optional, default empty)
the value for the property, shown as <input type="text" ... />. label (optional, default empty)
the label for the field. required (optional boolean, default 'false')
if true, will style the field with a CSS class "required_field". Is passed to @edit.field. size (optional, default '25')
the size of the input field in characters. CSS styling is preferrable to HTML size
changes, so override this option with care.
maxLength (optional, default empty)
the maxLength of the input field. readOnly (optional boolean, default 'false')
sets the input field to read only. disabled (optional boolean, default 'false')
disables the input field. onClick (optional, default empty)
JavaScript code to be executed on click. onChange (optional, default empty)
JavaScript code to be executed on change. onKeyUp (optional, default empty)
JavaScript code to be executed on key up. onKeyDown (optional, default empty)
JavaScript code to be executed on key down. prefixValue (optional, default empty)
a value to be displayed right before the %lt;input> element framed by <span>. showEmptyPrefix (optional boolean, default 'false')
if set to true it shows the <span> right before the %lt;input> element although
prefixValue is empty.
showErrorAsLabel (optional boolean, default 'false')
Default: errors are shown below the property field. If set to 'true', errors are shown
as labels. Is passed to @edit.field.
cssClass (optional, default empty)
a CSS class used for the <fieldset> element which frames the label and fields. Is passed
to @edit.field.

 

@edit.text

Shows an <textarea /> element to edit a property of an object. Used for long texts inside a form. It can only be used inside a form. Internally it calls the macro @edit.field and displays the textarea element with a label framed by a fieldset. Field errors are automatically added that the validation of the Struts action generated.

Parameters of @edit.text:

name (required)
the property name for this field. id (optional, default empty)
the id for the textarea. value (optional, default empty)
the value for the property, shown as <textarea ... />. label (optional, default empty)
the label for the field. required (optional boolean, default 'false')
if true, will style the field with a CSS class "required_field". Is passed to @edit.field. col (optional, default '25')
default number of columns (in characters) for the text area. CSS styling is preferrable
to HTML size changes, so override this option with care.
rows (optional, default '10')
default number of rows (in lines) for the text area. CSS styling is preferrable to HTML
size changes, so override this option with care.
showErrorAsLabel (optional boolean, default 'false')
Default: errors are shown below the property field. If set to 'true', errors are shown
as labels. Is passed to @edit.field.
cssClass (optional, default empty)
a CSS class used for the <fieldset> element which frames the label and fields. Is passed
to @edit.field.

 

@edit.hidden

Shows a hidden field and can only be used inside a form. Hidden fields are not displayed inside @edit.form elements.

Parameters of @edit.hidden:

name (required)
the property name for this field. id (optional, default empty)
the id for the input field. value (optional, default empty)
the value for the property, shown as <input type="hidden" />.

 

@edit.password

Shows a password field (i.e. an <input> field with type "password") that works much like the @edit.string, except that it never displays a value. It can only be used inside a form. Field errors are automatically added that the validation of the Struts action generated.

Parameters of @edit.password:

name (required)
the property name for this field. id (optional, default empty)
the id for the input field. value (optional, default empty)
the value for the property, shown as <input type="password" ... />. label (optional, default empty)
the label for the field. required (optional boolean, default 'false')
if true, will style the field with a CSS class "required_field". Is passed to @edit.field. size (optional, default '25')
the size of the input field in characters. CSS styling is preferrable to HTML size
changes, so override this option with care.
js (optional, default empty)
allows you to pass a JavaScript event listener, like "onclick=alert('click');" readOnly (optional boolean, default 'false')
sets the input field to read only. cssClass (optional, default empty)
a CSS class used for the <fieldset> element which frames the label and fields. Is passed
to @edit.field.

Example for @edit.form, @edit.string and @edit.hidden: Please note the beautiful code using the MVC approach (Struts, Hibernate, Freemarker): you can easily pass the properties of the object 'User' to the template like for example: 'value=user.signature'.

<@edit.form id="updateUser" formAction="${base}/admin/user/update.action">
   <@edit.hidden name="user.id" value=user.id?c />
   <@edit.language name="user.locale"
      label=action.getText("label.User.locale")+":"
      value=user.locale supportedLocales=action.language.supportedAdminLocales />
   <@edit.string name="user.login" size="15"
      label=action.getText("label.User.login")+":"
      value=user.login required=true />
   <@edit.string name="user.signature" size="40"
      label=action.getText("label.User.signature")+":"
      value=user.signature required=true />
   <@edit.string name="user.email" size="40"
      label=action.getText("label.User.email")+":" value=user.email/>
   <@edit.controls>
      <@edit.button label=action.getText("control.User.submit") />
   </@edit.controls>
</@edit.form>

Screenshot (example) for @edit.form, @edit.string, @edit.hidden and validation (field error):

edituser.png

 

@edit.date

Provides an input field for a date with a JavaScript datepicker. The required date format is determined by the locale submitted by the browser and defaults to U.S. format. Field errors are automatically added that the validation of the Struts action generated.

Parameters of @edit.date:

name (required)
the property name for this field. id (optional, default empty)
the id for the input field. value (optional, default empty)
the value for the property, shown as <input type="text" ... />. label (optional, default empty)
the label for the field. required (optional boolean, default 'false')
if true, will style the field with a CSS class "required_field". Is passed to @edit.field. size (optional, default '25')
the size of the input field in characters. CSS styling is preferrable to HTML size
changes, so override this option with care.
showClear (optional, default empty)
shows a link to clear the field clearLabel (optional, default 'action.getText("label.date.clear")')
adds a label to the link to clear the field, gets the default label from
message.properties
clearLink (optional, default javascript: void(0);)
adds a value to the link to clear the field clearClick (optional, default $('${id}').value='';)
JavaScript snippet to clear the field cssClearClass (optional, default empty)
adds a CSS class to the link to clear the field readOnly (optional boolean, default 'false')
sets the input field to read only. cssClass (optional, default empty)
a CSS class used for the <fieldset> element which frames the label and fields. Is passed
to @edit.field.

Example for @edit.date:

<@edit.date name="article.publishDate" 
   value=publishDate?if_exists readOnly=true
   label="${action.getText('label.article.publishDate')}:" />

 

@edit.controls

Shows a control area to place submit, cancel or reset buttons inside a form. Uses the element <div> to frame the control elements and is used in combination with the macro @edit.button.

Parameters of @edit.controls:

id (optional, default empty)
the id for the <div> element. cssClass (optional, default empty)
a CSS class used for the <div> element which frames the control elements.

 

@edit.button

Adds a button of the type 'submit', 'image' or 'button' to the control area. Should be used with the macro @edit.controls.

Parameters of @edit.button:

label (optional, default empty)
the label to displayed for the button. id (optional, default empty)
the id for the button. type (optional, default 'submit')
the type for the button. Accepted are: 'submit', 'image' or 'button'. onClick (optional, default empty)
JavaScript code to be executed on click. image (optional, default empty)
the URL to an image to be displayed for the type 'image'. style (optional, default empty)
a CSS style added to the button. disabled (optional boolean, default 'false')
adds a CSS class with the value 'disabled' to the button. cssClass (optional, default empty)
a CSS class used for the <div> element which frames the control elements.

Example for @edit.form, @edit.controls and @edit.button:

<@edit.form id="touchConfirmArticle"  ... 
onSubmit="save('overlayBox','${base}/admin/article/touch.action',this); >
   <@show.boxMessage title=action.getText("tab.article.refresh") ... />
   <@edit.controls>
      <@edit.button name="touchArticle"
         label=action.getText("control.Article.touch.submit") />
      <@edit.button label=action.getText("control.cancel") type="button"
         onClick="closeOverlayBox()" />
   </@edit.controls>
</@edit.form>

Screenshot (example) for @edit.form, @edit.controls and @edit.button:

refresh.png

 

@edit.checkBox

Creates a fieldset with a checkbox and label or only a checkbox in case label is empty string.

Parameters of @edit.checkBox:

label (required)
the label to be displayed for the checkbox. If empty string, checkbox is shown without
label.
name (optional, default empty)
the name of the checkbox. id (optional, default parameter 'name' if exists or 'chbx')
the id of the checkbox. onClick (optional, default empty)
JavaScript code to be executed on click. onChange (optional, default empty)
JavaScript code to be executed on change. checked (optional boolean, default 'false')
if true, the checkbox will be checked when shown. required (optional boolean, default 'false')
a CSS class added if the checkbox is required. disabled (optional boolean, default 'false')
disables the checkbox. cssClass (optional, default empty)
a CSS class used for checkbox and fieldset.

 

@edit.radioGroup

Creates a fieldset for a radio button group with label or only a radio button group in case label is empty string. Should be used with the macro @edit.radioOption (see below).

Parameters of @edit.radioGroup:

label (required)
the label to be displayed for the radio button group. If empty string, the radio button
group is shown without label.
name (optional, default 'rd')
the name of the radio button group. required (optional boolean, default 'false')
a CSS class added if the radio button group is required. cssClass (optional, default empty)
a CSS class used for radio button group and fieldset.

 

@edit.radioOption

Creates a radio button like <input type='radio' ... />. Should be used with the macro @edit.radioGroup (see above).

Parameters of @edit.radioOption:

label (optional, default empty)
the label to be displayed for the radio button. value (optional, default empty)
the value of the radio button. name (optional, default empty)
the name of the radio button. id (optional, default empty)
the id of the radio button. onClick (optional, default empty)
JavaScript code to be executed on click. onChange (optional, default empty)
JavaScript code to be executed on change. checked (optional boolean, default 'false')
if true, the radio button will be checked when shown. cssClass (optional, default empty)
a CSS class used for radio button.

 

@edit.select

Creates a fieldset with a select box (drop down list) and a label. In case you pass a collection of elements to the macro, it creates the option tags automatically. You can also nest the option tag yourself using the @edit.option macro (see below) and get a bit more control over the option tag.

Parameters of @edit.select:

label (required)
the label to be displayed for the select box. name (optional, default empty)
the name of the select box. id (optional, default empty)
the id of the select box. elements (optional, default empty)
a collection of elements to be shown as options in the field. selectedElement (optional, default empty)
the name of the selected element to be shown as the selected option. isMuliple (optional boolean, default 'false')
if true it allows multiple selection in a select box. size (optional, default '0')
the size of the select box. onChange (optional, default empty)
JavaScript code to be executed on change. required (optional boolean, default 'false')
a CSS class added if the select box is required. disabled (optional boolean, default 'false')
disables the select box. cssClass (optional, default empty)
a CSS class used for select box and the fieldset.

Examples for @edit.select:

<@edit.select name="zoneId" elements=zones property="name" />

The call above creates a select for the zones on the login page of the Tiny Marbles CMS admin page. It creates a <select> tag with name zoneId. For each of the elements, it will show an option with the element's id as value and label defined by the element's name property, like this:

<select id="Login_zoneId" name="zoneId">
  <option value="80">MUM Zone</option>
  <option value="82">Example Zone</option>
</select>

Alternatively, you can use your own nested options, the call above is equivalent to this one:

<@edit.select name="zoneId" elements=zones ; el >
  <@edit.option value=el.id?c label=el.name />
</@edit.select>

 

@edit.option

Shows a select option, usually nested in select calls (see @edit.select above).

Parameters of @edit.option:

label (optional, default empty)
the option label, i.e. what is shown to the user. Nested content as option label. value (required)
the option value, i.e. what is sent to the server. id (optional, default empty)
the id of the option tag. selected (optional boolean, default 'false')
if true, the option will be marked as selected in the resulting HTML.

Examples for @edit.option:

Since there are already examples in the @edit.select above, here a complicated label and selection. Let's say you have a collection of Feed objects with two parameters, "title" and "url". You want to show the title, with the url in parenthesis:

<@edit.select name="feedId" elements=feeds ; el >
  <@edit.option value=el.id?c >
    ${el.title?html} (${el.url?html})
  </@edit.option
</@edit.select>

rank tracker . online chemist shop instructor told me at last to be able to http://quick-views.com/ actually purchase