predefined properties

Hello, this question may sound a bit basic, but I have struggled to find a reference to the problem, The question have is
Can I use a predefined property in bits of javascript code within an action just like I m able to within simple actions.

For example if I had a pop up like this:

  <action-popup name="PageTitle" title="Page Title">
  <value name="&_pagetitle;" title="freeway generated page title" />
  <value name="generic" title="generic page title" />
  </action-popup>

now this would apply the variable (page title) which would either be the freeway generated page title or the word “generic”, anywhere I had placed the variable in a line of script like:

  <P> Hello! this page is titled "&PageTitle;"< /P>

but how can I do this if I wanted to do the same within some script thats been added via fwAddRaw. I tried using the same method and it just returns &_pagetitle but it did add the word generic when I chose that in the menu, so I must be close… I hope

any help would be greatly appreciated

pems


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I haven’t tried this, but looking through the creaky-old API
reference, there’s something called fwSubstitute.

fwSubstitute(string)
This method will substitute variables of the form &param; 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.

This is a method of the fwAction class, so you will need a reference
to the current Action to use it. Try something like this (completely
untested):

function fwBeforeEndHTML(){
var me = this;
var str = ‘’;
alert(me.fwSubstitute(str));
}

Walter

On Nov 21, 2008, at 6:34 PM, pems wrote:

Hello, this question may sound a bit basic, but I have struggled to
find a reference to the problem, The question have is
Can I use a predefined property in bits of javascript code within
an action just like I m able to within simple actions.

For example if I had a pop up like this:

  <action-popup name="PageTitle" title="Page Title">
  <value name="&_pagetitle;" title="freeway generated page  

title" />

now this would apply the variable (page title) which would either
be the freeway generated page title or the word “generic”, anywhere
I had placed the variable in a line of script like:

  <P> Hello! this page is titled "&PageTitle;"< /P>

but how can I do this if I wanted to do the same within some script
thats been added via fwAddRaw. I tried using the same method and it
just returns &_pagetitle but it did add the word generic when I
chose that in the menu, so I must be close… I hope

any help would be greatly appreciated

pems


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walt thanks for coming back
but I am still not there. :frowning:
If I describe what I am trying to do then it may make it easier for you to see what or where I am going wrong.

I have been using a combination of your method and weavers slight alternative of replacing content within a div (you helped me out with some excellent examples some time ago)

You came up with this method.

 //get a reference to the item this action is applied to
 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');
 //make a new disposable tag to work with
 var dummy = fwDocument.fwTags.fwAdd('');
 //wrap this tag in a paragraph
 dummy = dummy.fwAddEnclosing('p',true);
 //add some text to it, the classic example text!
 dummy.fwAddRaw('Hello, world!');
 alert(dummy.fwToHTML());
 //just so you can see where you have gotten at this point
 myDiv.fwAdd(dummy);
 //add the new dummy tag into the found tag
 dummy.fwDelete();
 //delete the dummy, otherwise it will print in your final HTML as the last line of code

and weaver also wrote down an alternative to referencing the div which was

 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');
 //so we have a reference to our div to which we want to add the JS

 myDiv.fwAddRaw('string to add', myDiv);
 //______________________________^^^^^ new AFTER argument 

which has worked really well, and I have been using yours and weavers suggestions on how to get this to work. Now I am at a point were I would like to add some input from a drop down and one of those drop down options contains a built-in variable. Like a &_date or &_page.title

I have been successful in adding normal items like numbers and text into fwParameters but I cant seem to get the built variables to be recognized into some thing like below from a choice within a drop down

var theContent = myDiv.fwAddRaw( ' + fwParameters["PageTitle"].fwValue + '

Does this make sense, am I tackling this the correct way?
I am sorry if this seems to be going over old ground and I do appreciate the time every one has spent helping me out in the past, I will try to make the mental jump, I think I am not far off.

I did follow an example in the freeway actions document of:

<item-action name+"Image Border1">
<action-javascript>

 functions fwAtContent()
 {
     fwDocument.fwWrite(' border=1');
     fwDocument.fwWrite(' height=', fwHeight);

and then tried to adapt it to work in my example but this doesn’t work either
so again I have hit a brick wall.
So any help would be really appreciated

pems


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If your template text contains the &someParameter; notation, then
fwSubstitute() will replace those with their current values from the
fwParameters array.

Have a look in the Actions API reference, page 10.

Walter

On Nov 24, 2008, at 3:48 PM, pems wrote:

Hi Walt thanks for coming back
but I am still not there. :frowning:
If I describe what I am trying to do then it may make it easier for
you to see what or where I am going wrong.

I have been using a combination of your method and weavers slight
alternative of replacing content within a div (you helped me out
with some excellent examples some time ago)

You came up with this method.

 //get a reference to the item this action is applied to
 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');
 //make a new disposable tag to work with
 var dummy = fwDocument.fwTags.fwAdd('');
 //wrap this tag in a paragraph
 dummy = dummy.fwAddEnclosing('p',true);
 //add some text to it, the classic example text!
 dummy.fwAddRaw('Hello, world!');
 alert(dummy.fwToHTML());
 //just so you can see where you have gotten at this point
 myDiv.fwAdd(dummy);
 //add the new dummy tag into the found tag
 dummy.fwDelete();
 //delete the dummy, otherwise it will print in your final HTML  

as the last line of code

and weaver also wrote down an alternative to referencing the div
which was

 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');
 //so we have a reference to our div to which we want to add  

the JS

 myDiv.fwAddRaw('string to add', myDiv);
 //______________________________^^^^^ new AFTER argument

which has worked really well, and I have been using yours and
weavers suggestions on how to get this to work. Now I am at a point
were I would like to add some input from a drop down and one of
those drop down options contains a built-in variable. Like a &_date
or &_page.title

I have been successful in adding normal items like numbers and text
into fwParameters but I cant seem to get the built variables to be
recognized into some thing like below from a choice within a drop down

var theContent = myDiv.fwAddRaw( ' + fwParameters 

[“PageTitle”].fwValue + ’

Does this make sense, am I tackling this the correct way?
I am sorry if this seems to be going over old ground and I do
appreciate the time every one has spent helping me out in the past,
I will try to make the mental jump, I think I am not far off.

I did follow an example in the freeway actions document of:

<item-action name+"Image Border1">
<action-javascript>

 functions fwAtContent()
 {
     fwDocument.fwWrite(' border=1');
     fwDocument.fwWrite(' height=', fwHeight);

and then tried to adapt it to work in my example but this doesn’t
work either
so again I have hit a brick wall.
So any help would be really appreciated

pems


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Pems

As Walt mentioned… have a look specifically at example 1 page 11
(this is how I do some of my actions)
notice that there is a…

     var s="param1= &param1;

If you wanted to use this in your example you would need to use this bit without the param1=

so if we take your example which you have been successful with, you would then add

 var s="&param1;"; 

in front

 //get a reference to the item this action is applied to 
 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');

so it would now look like this:

 var s="&param1;";
 //get a reference to the item this action is applied to 
 var myDiv = fwDocument.fwTags.fwFind(fwItem,'div');

then where you have used fwParameters

 var theContent = myDiv.fwAddRaw( ' + fwParameters["param1"].fwValue +

you need to replace the specific fwParameter with fwSubstitute and reference the specific var so it would convert from this:

  + fwParameters 

to this…

  + fwSubstitute(s) +

I don’t know if this helps or not!!!.. it’s not the easiest thing to explain and I am sure others would be able to describe it clarity… but looking at what you were doing, I don’t think you were very far off.
In basic terms all you are doing is getting the predefined property result first, with var s="&param1;"; and then using that with fwSubstitute in place of fwParameters.

max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If i am interpreting your question correctly, the ultimate issue is how to add the FW page title (however dynamic that is) by a statically named fwParameter? That is to say, a user would select ‘Page Title’ from an Action widget and that parameter would always return the Page Title value?

fwSubstiute sounds like a fine method, though I have not used it myself. Ther desired result may dictate a slightly circuitous route. max is describing roughly my thoughts here, but I think it may be easier to see what is happening below:

<action-popup name="mySpecialPopup">
    <value name="page_title" title="FW generate Page Title">
    <value name="generic" title="Generic Value">
</action-popup>

The situation noted about your example popup is that the ‘names’ are a mix of potential system variables (&PageTitle;) and arbitrary text (‘generic’). Even if you set up the fwSubstitute path, how would it handle the value of ‘generic’?

Back to the above example: Now the parameter has some more ‘readable’ values. Basically, I would wash these through a ‘switch’ statement’ to determine the final values:

var finalTitle;  //final value that will be used elsewhere in the script

switch(fwParameters['mySpecialPopup'].fwValue){
    case 'page_title':
        finalTitle = fwPage.fwTitle;
        //long-hand of fwSubstitute('&PageTitle;');
        break;
    case 'generic':
        finalTitle = 'my generic page title value';
        break;
}

You now have the page ‘title’ stored in the ‘finalTitle’ variable, which may be used as needed, where ever you would like, without needing fwSubstitute or similar manipulations.

The loop above allows you to have meningful values for the parameters, and not tie the parameter values to a specific system variable. This abstracts the final valiue away from the parameter, making changes and alterations to the final value easier to maintain, as the parameter need never change. All the logic is handled in the ‘switch’ loop.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Coooor blimey thats a lot cleverrrer than mine… :o)
I knew someone would handle this sort of problem with a greater amount of finesse than I could muster…
I’m going to have a look at that my self… :o)…

max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hello Waltd, Weaver and Max
Thank you for explaining this problem in a step by step fashion.
I am pleased to say that at last I have understood the solution, with the result that I have managed to make it work… hooray!!
thanks again for all you patients.

pems


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options