cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <d...@c-ware.de>
Subject Re: Usage of jx:set tags
Date Wed, 01 Jun 2005 16:22:21 GMT
Thorsten Scherler wrote:

>On Wed, 2005-06-01 at 16:01 +0200, Christofer Dutz wrote:
>  
>
>>Thorsten Scherler wrote:
>>
>>    
>>
>>>On Wed, 2005-06-01 at 15:32 +0200, Christofer Dutz wrote:
>>> 
>>>
>>>      
>>>
>>>>Hi,
>>>>
>>>>how can I set a vaiable and use it outside the macro it das 
>>>>defined/redefined. Unfortunately the definitions/changes aren't 
>>>>accessible outside.
>>>>In my case I set a total variable to 0 and calculate a total over a 
>>>>repeater field (which works if I output the variables value inside the 
>>>>repeater loop).
>>>>Outside the loop all changes are lost. There has to be a way for me to 
>>>>do this calculation. Can anyone help me with this?
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>First define a global (outside) variable, then just add an on-submit
>>>event which will sync your global with your local variable (loop).
>>> 
>>>
>>>      
>>>
>>Am I correct that I have to completely throw overboard all techniques I
>>used to use in for example struts using STL?
>>    
>>
>
>;-) ...not all, but some really nice ones. ;-)
>
>  
>
>> Even if the tags are
>>allmost identical. I have to go the way of seting variables in my
>>flowscript and not in the page itself? 
>>    
>>
>
>I did not say that. I meant you define a <jx:set/> outside your
><ft:repeater-widget> and one inside. 
>  
>
Could you please help me and show me how I would have to do that. My
brain is sort of runn dry and I sort of get this choking feeling when
seeing the google search window ;)
Think I saw the google-search window about twice as often as a real
window in the last weeks ...

This is my template with the partly workling calculations :(

Thanks in advance,
    Chris

<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
    <!-- Import the macros that define CForms template elements -->
    <jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>

    <jx:set var="total" value="0"/>

    <title>Warenkorb</title>
    <include src="/shop/utils/forms-lib.js"/>
    <paragraph style="width:990px;height:445px">
        <ft:form-template action="#{$continuation/id}.continue"
method="POST">
            <paragraph style="width:990px;height:385px">
                <br/>
                <paragraph style="width:970px;height:25px;">
                    <paragraph
style="width:18px;height:25px;float:left;border:none;text-align:right;">
                        <image url="/images/popup-button-left.gif"
style="width:13px;height:25px;"/>
                    </paragraph>
                    <paragraph
style="width:140px;height:25px;float:left;background-color:rgb(60,70,131);text-align:left;">
                        <ft:repeater-widget-label id="cartContent"
widget-id="count"/>
                    </paragraph>
                    <paragraph
style="width:390px;height:25px;float:left;border:none;background-color:rgb(60,70,131);text-align:left;">
                        <ft:repeater-widget-label id="cartContent"
widget-id="product"/>
                    </paragraph>
                    <paragraph
style="width:200px;height:25px;float:left;border:none;background-color:rgb(60,70,131);text-align:left;">
                        <ft:repeater-widget-label id="cartContent"
widget-id="productNo"/>
                    </paragraph>
                    <paragraph
style="width:100px;height:25px;float:left;border:none;background-color:rgb(60,70,131);text-align:right;">
                        <ft:repeater-widget-label id="cartContent"
widget-id="price"/>
                    </paragraph>
                    <paragraph
style="width:100px;height:25px;float:left;border:none;background-color:rgb(60,70,131);text-align:right;">
                        <ft:repeater-widget-label id="cartContent"
widget-id="totalPrice"/>
                    </paragraph>
                    <paragraph
style="width:18px;height:25px;float:left;border:none;text-align:left;">
                        <image url="/images/popup-button-right.gif"
style="width:13px;height:25px;"/>
                    </paragraph>
                </paragraph>
                <jx:choose>
                    <jx:when
test="${widget.getChild('cartContent').getSize() > 0}">
                        <ft:repeater-widget id="cartContent">
                            <paragraph style="width:970px;height:25px;">
                                <paragraph
style="width:18px;height:25px;float:left;border:none;"/>
                                <paragraph
style="width:140px;height:25px;float:left;border:none;text-align:left;">
                                    <ft:widget id="count">
                                        <fi:styling style="width:60px"/>
                                    </ft:widget>
                                    <ft:widget id="deleteItem">
                                        <fi:styling type="image"
src="/images/delete.gif"/>
                                    </ft:widget>
                                    <jx:choose>
                                        <jx:when
test="${repeaterLoop.first}">
                                            <image
url="/images/transparent.gif" style="width:16px;height:16px;"/>
                                        </jx:when>
                                        <jx:otherwise>
                                            <ft:widget id="itemUp">
                                                <fi:styling type="image"
src="/images/up.gif"/>
                                            </ft:widget>
                                        </jx:otherwise>
                                    </jx:choose>
                                    <jx:choose>
                                        <jx:when
test="${repeaterLoop.last}">
                                            <image
url="/images/transparent.gif" style="width:16px;height:16px;"/>
                                        </jx:when>
                                        <jx:otherwise>
                                            <ft:widget id="itemDown">
                                                <fi:styling type="image"
src="/images/down.gif"/>
                                            </ft:widget>
                                        </jx:otherwise>
                                    </jx:choose>
                                </paragraph>
                                <paragraph
style="width:390px;height:25px;float:left;border:none;text-align:left;">
                                    <ft:widget id="product"/>
                                </paragraph>
                                <paragraph
style="width:200px;height:25px;float:left;border:none;text-align:left;">
                                    <ft:widget id="productNo"/>
                                </paragraph>
                                <paragraph
style="width:100px;height:25px;float:left;border:none;text-align:right;">
                                    <jx:formatNumber
value="${widget.getChild('price').getValue()}" type="currency"
currencyCode="EUR"/>
                                </paragraph>
                                <paragraph
style="width:100px;height:25px;float:left;border:none;text-align:right;">
                                    <jx:formatNumber
value="${widget.getChild('price').getValue() *
widget.getChild('count').getValue()}" type="currency"
currencyCode="EUR"/>
                                    <jx:set var="total" value="${total +
(widget.getChild('price').getValue() *
widget.getChild('count').getValue())}"/>
                                </paragraph>
                                <paragraph
style="width:18px;height:25px;float:left;border:none;"/>
                            </paragraph>
                        </ft:repeater-widget>
                    </jx:when>
                    <jx:otherwise>
                        Im Warenkorb befinden sich zur Zeit keine Produkte
                    </jx:otherwise>
                </jx:choose>
                <paragraph style="width:970px;height:25px;overflow:hidden;">
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                    <paragraph
style="width:830px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:left;">Gesamt


Bestellwert:</paragraph>
                    <paragraph
style="width:100px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:right;"><jx:formatNumber


value="${total}" type="currency" currencyCode="EUR"/></paragraph>
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                </paragraph>
                <paragraph style="width:970px;height:25px;overflow:hidden;">
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                    <paragraph
style="width:830px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:left;">Porto


&amp; Verpackung  (frei ab 100,00 Bestellwert):</paragraph>
                    <paragraph
style="width:100px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:right;"><jx:formatNumber


value="${0}" type="currency" currencyCode="EUR"/></paragraph>
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                </paragraph>
                <paragraph style="width:970px;height:25px;overflow:hidden;">
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                    <paragraph
style="width:830px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:left;">Gesamtpreis:</paragraph>
                    <paragraph
style="width:100px;height:25px;float:left;border-top-width:1px;border-top-style:solid;border-color:#CCCC99;text-align:right;"><jx:formatNumber


value="${0}" type="currency" currencyCode="EUR"/></paragraph>
                    <paragraph
style="width:20px;height:25px;float:left;border:none;"/>
                </paragraph>
            </paragraph>
            <paragraph style="width:570px;height:35px;margin-left:420px">
                <table style="width:570px;empty-cells:show">
                    <row>
                        <cell style="width:190px;tex-align:center">
                            <ft:widget id="updateButton">
                                <fi:styling type="image"
src="/images/buttons/Aktualisieren.png"/>
                            </ft:widget>
                        </cell>
                        <cell style="width:190px;tex-align:center">
                    </cell>
                        <cell style="width:190px;tex-align:center">
                            <ft:widget id="nextButton">
                                <fi:styling type="image"
src="/images/buttons/Weiter.png"/>
                            </ft:widget>
                        </cell>
                    </row>
                </table>
            </paragraph>
        </ft:form-template>
    </paragraph>
</page>

>  
>
>>This is a way I sort of havt to
>>get used to first since the normal STL way would be the much more
>>intuitive way and in the last few weeks it turned out that every problem
>>I had was because I didn't do it the "intuitive-way" because of the
>>"way-you-usually-have-to-do-it-way".
>>    
>>
>
>Yeah I am constantly running in the same problem ATM. Sadly I have as
>well a Struts background and trying things the old fashion way. 
>
>Personally I will investigate a wee bit more in the JavaFlow to use some
>of the "normal" way (beans,...).
>
>salu2
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message