This is the implementation of Second.
I also tried a version where the two datalinks point to two different
variables like
From Start to Second : counter -> counter
From Second to Second : counter2 -> counter2
It is possible to achieve the expected behavior this way but it looks wierd.
Tks
jm
public class Second extends Element {
private int counter;
private int increment;
public void setIncrement(int increment) {
System.out.println("Second.setIncrement()");
this.increment = increment;
}
public void setCounter(int counter) {
System.out.println("Second.setCounter(" + counter + ")");
this.counter = counter;
}
public void processElement() {
System.out.println("Second.processElement()");
Template template = getHtmlTemplate("second");
template.setValue("count", counter);
print(template);
}
public void doIncrease() {
System.out.println("Second.doIncrease()");
counter += increment;
processElement();
}
}
Geert Bevin wrote:
>
> What's the implementation of Second?
>
> On 12 Jan 2007, at 13:19, Jean-Marie Galliot wrote:
>
>>
>> Sorry, I made a mistake in copying the code. The second datalink is
>> in the
>> element Second like this:
>>
>> <site>
>> <arrival destid="Start"/>
>>
>> <element id="Start" url="/start" implementation="com.test.Start">
>> <exit name="started" />
>> <flowlink srcexit="started" destid="Second">
>> <datalink srcoutput="counter" destinput="counter"/>
>> </flowlink>
>> </element>
>>
>> <element id="Second" url="/second"
>> implementation="com.test.Second">
>> <input name="counter" />
>> <datalink srcoutput="counter" destinput="counter"
>> destid="Second" />
>> <submission name="increase">
>> <param name="increment" />
>> </submission>
>> </element>
>>
>>
>> Jean-Marie Galliot wrote:
>>>
>>> Hi,
>>>
>>> I have this simple site :
>>>
>>> <site>
>>> <arrival destid="Start"/>
>>>
>>> <element id="Start" url="/start" implementation="com.test.Start">
>>> <exit name="started" />
>>> <flowlink srcexit="started" destid="Second">
>>> <datalink srcoutput="counter" destinput="counter"/>
>>> </flowlink>
>>> <datalink srcoutput="counter" destinput="counter"
>>> destid="Second"
>>> />
>>> </element>
>>>
>>> <element id="Second" url="/second"
>>> implementation="com.test.Second">
>>> <input name="counter" />
>>> <submission name="increase">
>>> <param name="increment" />
>>> </submission>
>>> </element>
>>>
>>> </site>
>>>
>>> And this is the implementation of the element Start:
>>>
>>> public class Start extends Element {
>>>
>>> public void initialize() {
>>> System.out.println("Start.initialize");
>>> }
>>>
>>> public int getCounter() {
>>> System.out.println("Start.getCounter() = 3");
>>> return 3;
>>> }
>>>
>>> public void processElement() {
>>> System.out.println("Start.processElement()");
>>> exit("started");
>>> }
>>> }
>>>
>>> The output trace is:
>>> Start.initialize
>>> Start.processElement()
>>> Start.getCounter() = 3
>>> Start.getCounter() = 3
>>> Start.getCounter() = 3
>>> Guess.setCounter(3)
>>> Guess.processElement()
>>>
>>> Could you explain why getCounter() is called three times?
>>>
>>> Also, what I am trying to do is having this element Start
>>> initializing and
>>> transmitting a value to element Second.
>>> For the time being it'a a simple integer but it will be eventually
>>> a bean.
>>>
>>> Then, the subsequent requests will be processed by element Second.
>>> At each
>>> request, the value originally initialized by the element Start will
>>> evolve, so It will use a datalink from element Second to itself to
>>> keep
>>> the state like you suggested in the example : statefull components.
>>>
>>> But the problem is :
>>>
>>> Apparently, each time the element Second is processed (and not
>>> only the
>>> first time) the method getCounter of element Start is called and
>>> the value
>>> is set into element Second.
>>>
>>> I can understand why but how can we accomplish this simple behavior :
>>>
>>> Element second is initialized with a value from Element Start. But
>>> after
>>> that, the value is modified iteratively in element Second by the very
>>> process of subsequent requests, without the value being
>>> reinitialized each
>>> time by the element Start?
>>>
>>> I can imagine two datalinks with two distincts variables. Then
>>> element
>>> Second has to decide that the second variable (the one coming from
>>> himself) has precedence over the one coming from element Start.
>>> But it
>>> looks unnatural.
>>>
>>> Can you help?
>>>
>>> Tks
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/Datalink-
>> semantics-tf2965628.html#a8297430
>> Sent from the RIFE - users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Rife-users mailing list
>> [email protected]
>> http://lists.uwyn.com/mailman/listinfo/rife-users
>>
>
> --
> Geert Bevin
> Uwyn "Use what you need" - http://uwyn.com
> RIFE Java application framework - http://rifers.org
> Music and words - http://gbevin.com
>
>
> _______________________________________________
> Rife-users mailing list
> [email protected]
> http://lists.uwyn.com/mailman/listinfo/rife-users
>
>
--
View this message in context:
http://www.nabble.com/Datalink-semantics-tf2965628.html#a8297733
Sent from the RIFE - users mailing list archive at Nabble.com.
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users