tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Sampaleanu <colin...@exis.com>
Subject Re: It is annoying that Form's getLink() is private
Date Tue, 23 Sep 2003 22:29:31 GMT
I'm not clear on how implementing my own IForm interface wouldn't be a 
lot more work (and in fact how I would use it). So if I can subclass 
Form and override ILink, all I have to add to it is this:

    public abstract String getActionOverride();

    private ILink getLink(IRequestCycle cycle, String actionId)
    {
        if (getActionOverride() != null)
            return new StaticLink(getActionOverride());

        return super.getLink(cycle, actionId);
    }

then I create a new .jwc file which is a copy of the Form.jwc but adds:
  <parameter name="actionOverride"
          type="java.lang.String"
          required="no"
      direction="in">
    <description>
    Provides an override to set the action link directly. Used mainly 
for j_security_check.
    </description>
  </parameter>
 
and that's it (this raises the question, btw, if you can extend an 
existing .jwc file, which would be even simpler, but I presume that's 
not possible).

As for the input field names, j_username and j_password, they are set on 
the actual template html and the .page file for the login page, that has 
nothing to do with the Form component.

I actually have this working, but unfortunately I've had to completely 
copy the contents of Form and make a whole new class, since I couldn't 
override getLink().

In any case, I think there is enough of a case for allowing the action 
to be overriden on the standard Form and pointing somewhere else other 
than into Tapestry, so that you can use it as an output only mechanism 
(as far as Tapestry is concerned). You can then take advantage of the 
richer rendering and client-side Javascript, etc...

Regards,
Colin

Howard M. Lewis Ship wrote:

>You could create your own implementation of the IForm interface.
>
>Don't you need to name the input fields specially for j_security_check?
>
>--
>Howard M. Lewis Ship
>Creator, Tapestry: Java Web Components
>http://jakarta.apache.org/tapestry
>http://jakarta.apache.org/commons/sandbox/hivemind/
>http://javatapestry.blogspot.com
>
>  
>
>>-----Original Message-----
>>From: Colin Sampaleanu [mailto:colinml1@exis.com] 
>>Sent: Tuesday, September 23, 2003 4:14 PM
>>To: Tapestry development
>>Subject: It is annoying that Form's getLink() is private
>>
>>
>>I want to make a subclass of Form which allows the developer 
>>to specify 
>>the value of the html form element's 'action' attribute 
>>directly. This 
>>is so that I can can create a login form for j2ee container 
>>authentication and still use Tapestry's Form class and 
>>components like 
>>ValidField to output the form to the page. If I do not subclass Form, 
>>then I have no control over the contents of the 'action' 
>>link. I need to 
>>set the action link to '.../j_security_check'.
>>
>>Is there any chance getLink() in Form could be made protected 
>>instead of 
>>private?
>>
>>Optionally, Form could be modifed to have an optional new property 
>>called 'actionoverride'. If it exists, then getLink() would 
>>build a link 
>>from that. This is what I was planning to do in my subclass of Form 
>>actually.
>>    
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message