Class FWAction
Last edit by:
Walter Davis
8 Apr, 2009
Pages in this section:
- A Hello World tutorial
- Action Elements
- Class FWAction
- Class FWActionList
- Class FWAttribute
- Class FWColor
- Class FWLinkParameter
- Class FWListData
- Class FWOSAInterpreter
- Class FWOutput
- Class FWPage
- Class FWParameter
- Class FWParameterList
- Class FWTag
- Files and Freeway Actions
- General Properties and User Methods
- Organisation of Classes
- Specific Properties and User Methods
- Weaver
This class defines an instance of an action on a page. Every instance (occurrence) of an action on a page has a corresponding FWAction. All the user defined methods are called within the context of a FWAction. i.e. ‘this’ is the current FWAction.
Properties
fwActions
The list of Actions in which this Action appears, that is the list of Actions applied to the item or page where FWActionList this Action is applied.
fwAltText
The alt text that is applied to the Action’s item. Note you should call fwEncode before generating HTML String with it.
FwClearGif
Gives the relative path to the clear-gif from the current page (for example, “Resources/_clear.gif”). String
fwDocument
The Action document (the Freeway document in which the Action is used). FWDocument
fwFileName
Returns the relative path of the file to which the Action is being applied. The file will contain all or part of the String image (if the image is sliced). This is only available after or during fwAtContent. This can vary across different calls to fwAtContent if an object is sliced.
fwFolder
Immediate folder containing the page on which the Action appears. FWFolder
fwGeneratesForm
Determines whether this Action generates a form (and therefore does not need Freeway to generate a form). Boolean
fwGeneratesLink
Determines whether this Action generates a link (and therefore Freeway does not need to generate a link).Boolean
fwHeight
The height of the item, or part (if the image is sliced), on to which the Action is applied. This can vary across Integer different calls to fwAtContent if an object is sliced.
fwIndexOf
The zero-based index of this Action in the action list fwActions. Integer
fwItem
Item to which the Action is applied. FWElement
fwLayerName
The name of the layer on which the Action is applied. If there is no layer, an empty string is returned. String
fwMapName
The name of the image map associated with this item. This can vary across different calls to fwAtContent if an object is sliced. String
fwMarkups
The list of <action-markup> tags defined for this Action.
Examples:
<action-markup>
<action-html before-end-head>
<action-markup custom name=fred>
These can be named and then easily referenced by name. They are
particularly useful to store pieces of raw text to be output by the Action.
<action-html> is a synonym for <action-markup>.
fwPage
Page on which the Action appears. FWPage
f###wParameters
The list of parameters which this Action has. FWParameterList
fwRequiresForm
Determines whether this Action requires a form in order to be generated (for example, if it outputs a text field or Boolean button which needs to be contained in a form).
fwTitle
Name of the Action. String
fwWidth
The width of the item or part (if the image is sliced), on to which the Action is applied. This can vary across Integer different calls to fwAtContent if an object is sliced.
Methods
fwSubstitute(string)
This method will substitute variables of the form ¶m; with their values
from the Action parameter list (in the same way that it occurs in the Simple
Actions language). Returns a string with the parameters substituted.
Example 1:
This example has a string into which the parameters param1 and param2 are substituted.
<page-action name="Substitute Test 1">
<action-text name="param1" default=a>
<action-text name="param2" default=b>
<action-javascript>
function fwAfterEndHTML()
{
var s="param1= ¶m1; param2= ¶m2;";
alert(s);
alert(fwSubstitute(s));
}
</action-javascript>
</page-action>
Example 2:
You can also use
<page-action name="Substitute Test 2">
<action-text name="param1" default=c>
<action-text name="param2" default=d>
<action-markup custom name="mytext">
param1= ¶m1; param2= ¶m2;
</action-raw>
<action-javascript>
function fwAfterEndHTML()
{
var s=fwMarkups.mytext;
alert(s);
alert(fwSubstitute(s));
}
</action-javascript>
</page-action>
User Methods
These methods if present in your Freeway Action will be called in the places that their name suggests. This gives your Action an opportunity to add to the HTML that is generated by Freeway at a specific point in the output.
Example:
The following code would insert the word “wibble” just before the end of
the header (ie before </Head>) of the published HTML file.
fwBeforeEndHead()
fwDocument.fwWrite (“wibble’);
is equivalent to
<action-markup before-end-head> wibble </action-markup >
Positions for insertion point which mirror specific points in the output:
fwAfterEndBody()
fwAfterEndForm()
fwAfterEndHead()
fwAfterEndHTML()
fwAfterEndNoFrames()
fwAfterEndTable()
fwAfterStartBody()
fwAfterStartForm()
fwAfterStartHead()
fwAfterStartHTML()
fwBeforeEndBody()
fwBeforeEndForm()
fwBeforeEndHead()
fwBeforeEndHTML()
fwBeforeEndNoFrames()
fwBeforeEndTable()
fwBeforeStartBody()
fwBeforeStartForm()
fwBeforeStartHead()
fwBeforeStartHTML()
fwAfterStartNoFrames()
fwAfterStartTable()
fwBeforeStartNoFrames()
fwBeforeStartTable()
fwAtContent()
This method, if present in your Freeway Action, is called when the content
of an image would be written. If this method is present then Freeway will
not write the <img> tag. Instead it will rely on your Freeway Action to
generate the entire content for the item (for example, the <img> tag for an
image) in your fwAtContent method.
fwIsDirty()
This method, if present in your Freeway Action, is called before your page is published. It gives your Action a chance to force Freeway to republish a page when Freeway does not think that the page is needs to be republished. The fwIsDirty method will only be called if Freeway believes your page does not need to be republished. This is because if your page is dirty then Freeway has no need to call your fwIsDirty method, as it will republish your page anyway. Returns: Returns true if the page is “dirty” and should be republished.
Example 1:
This example will always force the current page to be republished.
function fwIsDirty()
{
return true;
}
Example 2:
This example method looks at the “Last Page” parameter and compares it against the next page in the containing folder. If it is different then it marks the page as dirty.
function fwIsDirty()
{
// if the last page generated is not the same as 'current' page
// then we are dirty
var nextPage = fwFolder.fwNextPage(fwPage);
var currPage = fwParameters["Last Page"].fwValue.fwInternal;
return nextPage != currPage;
}
fwInterface
This method, if present, is called when the Actions palette is being set up. It allows you to perform any functions required and set necessary values to display in the interface
