Skip to content

XAware Community

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
XAware 5.6
Need Help
Webinars and Events
Advanced Tutorials
Webinars and Events

You are here: Home arrow Forums
XAware Community Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Re:"for" cicle snippet (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:"for" cicle snippet
#4745
prichards (Admin)
Admin
Posts: 319
User Offline Click here to see the profile of this user
Re:"for" cicle snippet 11 Years, 1 Month ago Karma: 18  
The xa:loop and xa:if are new features for 5.4. The features were implemented over several internal iterations, so you may have a slightly different version depending on which build you tried. These should be fully implemented in the most recent builds; I am testing with the 5.4 Beta release (build 300) and they will be available in our GA release due out next week. The Designer Help documentation has also been updated for these two features (although there may be a couple portions that will be updated before GA).

Build 300 does include a snippet for xa:loop, which looks like the following:

<xa:loop xa:initialize="$xaware:setSessionVariable(i,0)$" xa:condition="$xavar:i$ &lt; 10" xa:adjustment="$xaware:addToSessionVariable(i,1)$">
<iteration number="$xavar:i$" />
</xa:loop>

I believe only xa:condition is required, which will execute the loop as long as the condition remains true. The example above illustrates how you can use xa:initialize and xa:adjustment with an XAware SessionVariable (see functoids) to modify the value used in the condition, so that you execute this loop 10 times (i.e., for 0..9).

For both the xa:loop and xa:if constructs, the xa:condition is evaluated and if the value is "true", the child elements of the condition (loop, if, else, etc.) are executed. You can use a Functoid or an XAware/XPath expression (allowing XAware substitutions for parameters and element references, and XPath functions) for the condition. One thing to realize is that you must use the correct XPath sytnax. The case above compares an XAware variable to a numeric value so it looks like: "$xavar:i$ < 10". When you compare strings in XPath expressions, single-quotes are required, so a condition to compare an XAware parameter to a value might look something like: " '%state%' = 'CO' ".

Beta (build 300) and later builds, include snippets for Loop, If, and If-elseif-else examples, and all execute correctly as is. You need to create an input parameter named "value" to test various values for the if-elseif-else snippet which is:

<xa:if xa:condition="%value% &gt; 10">
<doSomething />
</xa:if>
<xa:elseif xa:condition="%value% &gt; 5">
<doSomethingElse />
</xa:elseif>
<xa:else>
<otherwiseDoThis />
</xa:else>

For all of the snippets, you can add your own elements (or replace the <iteration/> or <dosomething/> under each condition, including using BizDoc/BizComp references to execute other components.

In order to pass different values to a SQL BizComp that you are calling N times, you will need to reference some other value (such as the index in the example above, or the Nth elemnt in a hierarchy) to pass dynamic values to the SQL BizComp. If you have a particular example that you can post, or an example that is not working correctly, we can review it and make some further suggestions.

Finally, I wanted to note that you can continue to use iteration techniques that we have used before xa:loop was introduced. A BizDoc or BizComp is executed once for each matching element specified by xa:input. So if you have a repeating XML structure containing 10 elements, and pass that reference as xa:input, the BizDoc/BizComp will execute 10 times; there is no need for an explicit loop. This is also very useful when you don't know how many input structures you are receiving in each execution - if you have 11 it will execute 11 times, if you have none, it will execute 0 times. In many cases, the dynamic values you want to pass to your SQL BizComp are often contained in an XML structure, so the BizComp is executed the correct number of times, with different values for each execution (such as inserting order items into a database, as shown in some of the tutorials). Again, if you have a specific example you are trying to get working, please attach it to the post, and we'd be happy to review it.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
      Topics Author Date
    thread link
"for" cicle snippet
cha0s 2009/06/06 11:38
    thread link
thread linkthread link Re:"for" cicle snippet
prichards 2009/06/08 12:51
    thread link
thread linkthread linkthread link Re:"for" cicle snippet
cha0s 2009/06/10 19:19
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Community Login

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
Commercial
Free Training
QuickStart Packages
Image 4 Title
Image 5 Title

Visit XAware.com