tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard M. Lewis Ship (JIRA)" <tapestry-...@jakarta.apache.org>
Subject [jira] Resolved: (TAPESTRY-522) LinkSubmit component registers for focus but can't receive it
Date Fri, 09 Sep 2005 12:29:30 GMT
     [ http://issues.apache.org/jira/browse/TAPESTRY-522?page=all ]
     
Howard M. Lewis Ship resolved TAPESTRY-522:
-------------------------------------------

    Resolution: Duplicate
     Assign To: Howard M. Lewis Ship

> LinkSubmit component registers for focus but can't receive it
> -------------------------------------------------------------
>
>          Key: TAPESTRY-522
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-522
>      Project: Tapestry
>         Type: Bug
>   Components: Framework
>     Versions: 4.0
>     Reporter: Raphael Jean
>     Assignee: Howard M. Lewis Ship

>
> The LinkSubmit component registers for focus during render, like all AbstractFormComponent's
by default.
> The client-side javascript generated looks like: 
> focus(document.$Form$0.$LinkSubmit);
> This is invalid since the LinkSubmit component is implemented with an <A> tag,
which is not an HTML form control.
> A quick and dirty fix is to override the renderComponent() method in LinkSubmit and omit
the calls to registerForFocus():
> protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
>         IForm form = TapestryUtils.getForm(cycle, this);
>         setForm(form);
>         if (form.wasPrerendered(writer, this))
>             return;
>         IValidationDelegate delegate = form.getDelegate();
>         delegate.setFormComponent(this);
>         setName(form);
>         if (form.isRewinding())
>         {
>             if (!isDisabled())
>             {
>                 rewindFormComponent(writer, cycle);
>             }
>         }
>         else if (!cycle.isRewinding())
>         {
>             renderFormComponent(writer, cycle);
>         }
> }
> This leads to code duplication... 
> A cleaner solution would be to add a method in AbstractFormComponent:
> public abstract boolean wantsFocus() {
>     return true;   // Wants focus by default
> }
> which could be overridden in subclasses for components that do not want focus.
> This method would be called in renderComponent() to check if the component wants focus
or not.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
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