liigo wrote:
Hi all!
I want to do this:
increase a counter(a persist propery) when user click a DirectLink.
and when i click the DirectLink, it works well,
but when i click the IE's Refresh button, the counter increase too! why?
I don't know why the listener methods will be executed when the page is
"Refresh"?
this is my java code:
--------------------------------------------------------------------------
package pages.login;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.IRequestCycle;
public abstract class MyPage extends BasePage
{
public abstract int getValue();
public abstract void setValue(int value);
public MyPage()
{
}
public void doClick()
{
setValue(getValue() + 1);
}
}
--------------------------------------------------------------------------
this is *.page:
--------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="pages.login.MyPage">
<property name="value" persist="session"/>
</page-specification>
--------------------------------------------------------------------------
and this is the html:
--------------------------------------------------------------------------
<html>
<h1>Liigo's Page</h1>
<p>
value: <span jwcid="@Insert" value="value">000</span>
<p>
<a href="#" jwcid="@DirectLink" listener="doClick">Click me</a>
<p>
<a href="#" jwcid="@PageLink" page="Home">to Home Page</a>
<p>
<a href="#" jwcid="@PageLink" page="login/Basic">to Basic Page</a>
</html>
--------------------------------------------------------------------------
thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
By pressing link associated with listener method, you simply send
request to aserver
( tomcat or any other ) with parameters, which describes your operation.
And as result, server
creates a html page. In your case you send link which increase counter
and displays result.
Link, which do this is still in address bar.By pressing Refresh in your
Browser you prevent
it to reread html associated with current link, but for server itis just
another request to "increase
counter and show result". It can be solved by do redirect after getting
result ( this is common practise ), but I am new to Tapestry and can't
tell you how todo it :(
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]