You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org> on 2009/04/23 23:07:30 UTC

[jira] Created: (WICKET-2238) Keep auto-components after rendering

Keep auto-components after rendering
------------------------------------

                 Key: WICKET-2238
                 URL: https://issues.apache.org/jira/browse/WICKET-2238
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
            Reporter: Ricardo Mayerhofer
            Priority: Minor


Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.

The code is located in MarkupContainer.java:
if (component.isAuto()) { children_remove(i); }

Thanks for considering.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-2238) Keep auto-components after rendering

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-2238:
----------------------------------

    Fix Version/s: 1.5-M1

right, i thought that restriction might have been lifted under certain conditions, but i guess not.

i dont think we can easily do this because you can try to add a component to a parent that has already been rendered, what happens then? there is no guarantee about the render order, thus the restriction - because resolvers are used "just-in-time" during the rendering process.

this is something that was easily accommodated in the now dead 2.0 version, because there we had access to markup prior to render. we might try and implement something like that in 1.5 if we find a way.

some thoughts:

we can perform a cascading "attached" call to components as they are being added and we can resolve the markup. so container.add() can look something like this:

container.add(component child) {
  // do whatever it does currently 
  if (getpage()!=null) {
   // if we already have the page we can figure out this component's markup
   IMarkupFragment fragment=findMarkupFragmentForChild(child);
   child.attachToMarkup(fragment);
}

child.attachToMarkup() will have to cascade the call to all its children, this way all components will eventually receive the "attached" callback no matter what stage of the game they are being added to the page - during construction or even during render.

once this is in place the textfields can be added automatically, even rewriting the markup if needed (such as adding wicket:ids dynamically) once the attached callback is received.


> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795913#action_12795913 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

It's seems to work fine, except in one situation. 
Because getParent of a page is always null, when you add a component directly to the page, the onMarkupAttached() method of this component is never called. It breaks in the following verification:

if ((getParent() != null) && (child.getMarkup() != null)) 
Line: 154 
MarkupContainer.java

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702504#action_12702504 ] 

Igor Vaynberg commented on WICKET-2238:
---------------------------------------

have you tried using the regular add() method in your resolver? you will have to add a guard so that the resolver, which runs on every render, doesnt try to add the same component twice.

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12792512#action_12792512 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

Great, I will start to play with it.

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-2238) Keep auto-components after rendering

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-2238.
----------------------------------------

    Resolution: Fixed

implemented in 1.5

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702450#action_12702450 ] 

Juergen Donnerstag commented on WICKET-2238:
--------------------------------------------

I don't think we'll fix it. They are called auto-components because they are automatically created with each render cycle. If we wouldn't remove them, you would end up with plenty un-used components and of course would get a lot of error message saying that component haven't been rendered. Please provide a proper use case and a quickstart. 

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795915#action_12795915 ] 

Juergen Donnerstag commented on WICKET-2238:
--------------------------------------------

fixed already

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790190#action_12790190 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

Hi Juergen,
Have you committed to trunk? I couldn't find your changes.

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702472#action_12702472 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

Juergen,
Thanks for your response.

A common complaint is duplication between html and java structure. I think many times this can be avoided. A common use case is a input form. Eg.:

setModel( new CompoundPropertyModel( object ) );
add( new TextField( "field1" ) );
add( new TextField( "field2" ) );
add( new TextField( "field3" ) );
...
<input type="text" wicket:id="field1"/>
<input type="text" wicket:id="field2"/>
<input type="text" wicket:id="field3"/>
....

To change this one could add a component resolver that maps, for example, html input to TextField component and so on, so that the only work needed is to set the model in form. Much easier considering that most inputs are added as TextFields, perhaps 80/20 rule Eg.:
Form:
setModel( new CompoundPropertyModel( object ) );

Component resolver:
if ( componentTag.getName().equals( "input" ) ){ 
markupContainer.autoAdd( new TextField( componentTag.getId() ), markupStream );
}

This component resolver currently doens't work because auto components are removed. I think this could add a lot of flexibility to wicket and enable programmers to simplify code base in database driven web application.

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703246#action_12703246 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

That's great Igor!

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702537#action_12702537 ] 

Ricardo Mayerhofer commented on WICKET-2238:
--------------------------------------------

Hi Igor,
If I use the regular add method I get the following error:
WicketMessage: Cannot modify component hierarchy after render phase has started (page version cant change then anymore)

I think this has to do with the following thread: http://osdir.com/ml/java.wicket.devel/2005-03/msg00552.html

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Priority: Minor
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (WICKET-2238) Keep auto-components after rendering

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag reassigned WICKET-2238:
------------------------------------------

    Assignee: Juergen Donnerstag

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-2238) Keep auto-components after rendering

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790242#action_12790242 ] 

Juergen Donnerstag commented on WICKET-2238:
--------------------------------------------

yes, it's in trunk (1.5; not 1.4 head). Look for Component.onMarkupAttached()

http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?revision=890074&view=markup

> Keep auto-components after rendering
> ------------------------------------
>
>                 Key: WICKET-2238
>                 URL: https://issues.apache.org/jira/browse/WICKET-2238
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> Auto-components are removed after rendering, so components added through component resolvers that take user input don't work.
> The code is located in MarkupContainer.java:
> if (component.isAuto()) { children_remove(i); }
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.