Basic usage of ILink to go to next page.  This is a listener method.

        public ILink doNextPage() {
                return getPageService().getLink(false, "pages/TheSecondPage");
        }

Example of ILink in a real life situation - logging in. This is a listener on the Log In button.

        @Bean
        public abstract ValidationDelegate getValidationDelegate();

        public ILink doLogin() {
                ILink redirectTo = null;

                try {
                        // If errors already detected by validators, return 
without redirect
                        if (getValidationDelegate().getHasErrors()) {
                                return null;
                        }

                        // Authenticate the user, password
                        // ...insert code...

                        // Redirect to WelcomePage
                        redirectTo = getPageService().getLink(false, 
"pages/WelcomePage");
                        return redirectTo;
                }
                catch (MyAuthenticationException e) {
                        recordError(e.toString());
                }
                catch (Exception e) {
                        // This should never happen, but we've caught it just 
in case
                        // (and should probably log it instead of just printing 
stack trace)
                        e.printStackTrace();
// Display general error, retrieving message from application's .properties file
                        recordError(getMessages().getMessage("login_problem"));
                }

                return redirectTo;
        }

        protected void recordError(String message) {
                ValidationDelegate delegate = getValidationDelegate();
                delegate.setFormComponent(null);
                delegate.record(message, null);
        }

HTH,

Geoff
http://files.doublenegative.com.au/jumpstart

On 05/06/2007, at 7:18 PM, Kushan Jayathilake wrote:

Hi

Im new to tapestry, and dont know much
Anyone can give me examples of using ILink interface

Plz give me some actual codings that you guys used ILink


Regards
Kushan

Reply via email to