You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Raphael Jean (JIRA)" <ta...@jakarta.apache.org> on 2005/08/02 16:04:37 UTC

[jira] Created: (TAPESTRY-522) LinkSubmit component registers for focus but can't receive it

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


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


[jira] Resolved: (TAPESTRY-522) LinkSubmit component registers for focus but can't receive it

Posted by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org>.
     [ 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


[jira] Commented: (TAPESTRY-522) LinkSubmit component registers for focus but can't receive it

Posted by "Raphael Jean (JIRA)" <ta...@jakarta.apache.org>.
    [ http://issues.apache.org/jira/browse/TAPESTRY-522?page=comments#action_12317493 ] 

Raphael Jean commented on TAPESTRY-522:
---------------------------------------

Forgot to mention tapestry version: 4.0 beta 3

The same problem occurs for the Hidden component.

> 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

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