solution:

resource format :

Have you forgotten your [EMAIL PROTECTED]:passwordForgotten}password{/@} or your [EMAIL PROTECTED]:nickForgotten}nick{/@}?


===================================================================
package net.tutim.tapestry.components.nestedlink;

import org.apache.tapestry.AbstractComponent;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.IEngineService;
import org.apache.tapestry.engine.ILink;
import org.apache.tapestry.util.RegexpMatch;
import org.apache.tapestry.util.RegexpMatcher;

public abstract class NestedPageLink extends AbstractComponent {
        
        public abstract String getMessage();
        public abstract IEngineService getPageService();

        @Override
        protected void renderComponent(IMarkupWriter writer, IRequestCycle 
cycle) {
                
                String message = getMessage();
                
                RegexpMatcher matcher = new RegexpMatcher();
RegexpMatch[] links = matcher.getMatches("\\{@([^>]*)\\}([^\\{]*)\\{/@\\}", message);
                
                for (RegexpMatch match : links ) {
                        writer.print(message.substring(0, 
message.indexOf(match.getInput())));
                        writeLink(writer, cycle, match.getGroup(1), 
match.getGroup(2) );
                        message = message.substring( message.indexOf("{/@}") + 
4);
                }
                
                writer.print(message);
                
        }
        
private void writeLink(IMarkupWriter w, IRequestCycle cycle, String page, String linkText) {
                
                ILink link = getPageService().getLink(cycle, false, page);
                
                w.begin("a");
                w.attribute("href", link.getURL());
                renderInformalParameters(w,cycle);
                
                w.print(linkText);
                
                w.end();
        }
}

==================================================================================

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
<component-specification allow-body="no" class="net.tutim.tapestry.components.nestedlink.NestedPageLink"
         allow-informal-parameters="yes">
        
        <parameter name="message" required="yes"/>
        
        <inject property="pageService" object="engine-service:page"/>

</component-specification>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to