You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by galbelli <ga...@apollocapital.com> on 2008/06/12 00:39:02 UTC

How to add a TextField in a Dynamically created DefaultDataTable

I am creating a DefaultDataTable dynamically as I only know the number of
columns at runtime. All is working nicely but I now need to have one of the
columns contain a TextField and not a Label. I am receiving the following
error: 

WicketMessage: Component cell must be applied to a tag of type 'input', not
'' (line 0, column 0)

How can I control the markup so I may change the HTML from span to input? 
-- 
View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add a TextField in a Dynamically created DefaultDataTable

Posted by Igor Vaynberg <ig...@gmail.com>.
your textfield doesnt have a model

-igor

On Thu, Jun 12, 2008 at 11:06 AM, galbelli <ga...@apollocapital.com> wrote:
>
> Thanks, the Fragment example did help in that I have the table rendering
> properly. When I attempt to submit the form I get the following error:
>
> WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
> [MarkupContainer [Component id = form, page =
> com.apollo.pricing.ui.HomePage, path =
> 0:tabs:panel:form.PricingBySourcePanel$1, isVisible = true, isVersioned =
> true]] threw an exception
>
> Root cause:
>
> java.lang.IllegalStateException: Attempt to set model object on null model
> of component: tabs:panel:form:table:rows:4:cells:11:cell:edit
> at org.apache.wicket.Component.setModelObject(Component.java:2510)
> at
> org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1002)
> at org.apache.wicket.markup.html.form.Form$14.validate(Form.java:1642)
> at
> org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form.java:160)
> at
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:403)
>
> Any ideas?
>
>
>
>
>
> jwcarman wrote:
>>
>> The markup for the datatable uses <div> (or maybe span) for each
>> cell's item.  So, you need to give it something that it can put on a
>> span.  That would be a panel or fragment (as suggested).  Did you see
>> my earlier post about a FragmentColumn class?  It might be useful in
>> your case.
>>
>> On Thu, Jun 12, 2008 at 12:50 PM, galbelli <ga...@apollocapital.com>
>> wrote:
>>>
>>> Not sure I understand how to accomplish this. Even if I wrap it in a
>>> panel
>>> won't it be looking for markup?
>>>
>>> My current markup for the dynamic table is as follows:
>>>
>>> <html xmlns:wicket="http://wicket.apache.org/">
>>>
>>>    <head>
>>>        <title>Prices by Source</title>
>>>    </head>
>>>    <body>
>>>            <wicket:panel>
>>>                    <br>
>>>                <form wicket:id="form">
>>>                        Portfolio: <select
>>> wicket:id="portfolioSelect"></select>
>>>
>>>                    <table class="dataview" cellspacing="0"
>>> wicket:id="table">
>>>                    </table>
>>>
>>>                </form>
>>>            </wicket:panel>
>>>    </body>
>>> </html>
>>>
>>> And the code"
>>>
>>>
>>>        List<IColumn> columns = new ArrayList<IColumn>();
>>>
>>>        columns.add(new PropertyColumn(new Model("CUSIP"), "cusip",
>>> "cusip"));
>>>        columns.add(new PropertyColumn(new Model("Description"),
>>> "description", "description"));
>>>
>>>        PropertyColumn aPropertyColumn = new PropertyColumn(new
>>> Model("Override"), "overridePrice", "overridePrice")
>>>        {
>>>            public void populateItem(Item item, String componentId, IModel
>>> model)
>>>            {
>>>                TextField aTextField = new TextField(componentId);
>>>                item.add(aTextField );
>>>            }
>>>
>>>        };
>>>        columns.add(aPropertyColumn);
>>>
>>>       DefaultDataTable aDefaultDataTable = new DefaultDataTable("table",
>>> columns, portfolioProvider, 8);
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> wrap the textfield in a fragment or a panel
>>>>
>>>> -igor
>>>>
>>>> On Wed, Jun 11, 2008 at 3:39 PM, galbelli <ga...@apollocapital.com>
>>>> wrote:
>>>>>
>>>>> I am creating a DefaultDataTable dynamically as I only know the number
>>>>> of
>>>>> columns at runtime. All is working nicely but I now need to have one of
>>>>> the
>>>>> columns contain a TextField and not a Label. I am receiving the
>>>>> following
>>>>> error:
>>>>>
>>>>> WicketMessage: Component cell must be applied to a tag of type 'input',
>>>>> not
>>>>> '' (line 0, column 0)
>>>>>
>>>>> How can I control the markup so I may change the HTML from span to
>>>>> input?
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17804562.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17806187.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add a TextField in a Dynamically created DefaultDataTable

Posted by galbelli <ga...@apollocapital.com>.
Thanks, the Fragment example did help in that I have the table rendering
properly. When I attempt to submit the form I get the following error: 

WicketMessage: Method onFormSubmitted of interface
org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
[MarkupContainer [Component id = form, page =
com.apollo.pricing.ui.HomePage, path =
0:tabs:panel:form.PricingBySourcePanel$1, isVisible = true, isVersioned =
true]] threw an exception

Root cause:

java.lang.IllegalStateException: Attempt to set model object on null model
of component: tabs:panel:form:table:rows:4:cells:11:cell:edit
at org.apache.wicket.Component.setModelObject(Component.java:2510)
at
org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1002)
at org.apache.wicket.markup.html.form.Form$14.validate(Form.java:1642)
at
org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form.java:160)
at
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:403)

Any ideas?





jwcarman wrote:
> 
> The markup for the datatable uses <div> (or maybe span) for each
> cell's item.  So, you need to give it something that it can put on a
> span.  That would be a panel or fragment (as suggested).  Did you see
> my earlier post about a FragmentColumn class?  It might be useful in
> your case.
> 
> On Thu, Jun 12, 2008 at 12:50 PM, galbelli <ga...@apollocapital.com>
> wrote:
>>
>> Not sure I understand how to accomplish this. Even if I wrap it in a
>> panel
>> won't it be looking for markup?
>>
>> My current markup for the dynamic table is as follows:
>>
>> <html xmlns:wicket="http://wicket.apache.org/">
>>
>>    <head>
>>        <title>Prices by Source</title>
>>    </head>
>>    <body>
>>            <wicket:panel>
>>                    <br>
>>                <form wicket:id="form">
>>                        Portfolio: <select
>> wicket:id="portfolioSelect"></select>
>>
>>                    <table class="dataview" cellspacing="0"
>> wicket:id="table">
>>                    </table>
>>
>>                </form>
>>            </wicket:panel>
>>    </body>
>> </html>
>>
>> And the code"
>>
>>
>>        List<IColumn> columns = new ArrayList<IColumn>();
>>
>>        columns.add(new PropertyColumn(new Model("CUSIP"), "cusip",
>> "cusip"));
>>        columns.add(new PropertyColumn(new Model("Description"),
>> "description", "description"));
>>
>>        PropertyColumn aPropertyColumn = new PropertyColumn(new
>> Model("Override"), "overridePrice", "overridePrice")
>>        {
>>            public void populateItem(Item item, String componentId, IModel
>> model)
>>            {
>>                TextField aTextField = new TextField(componentId);
>>                item.add(aTextField );
>>            }
>>
>>        };
>>        columns.add(aPropertyColumn);
>>
>>       DefaultDataTable aDefaultDataTable = new DefaultDataTable("table",
>> columns, portfolioProvider, 8);
>>
>>
>>
>>
>>
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> wrap the textfield in a fragment or a panel
>>>
>>> -igor
>>>
>>> On Wed, Jun 11, 2008 at 3:39 PM, galbelli <ga...@apollocapital.com>
>>> wrote:
>>>>
>>>> I am creating a DefaultDataTable dynamically as I only know the number
>>>> of
>>>> columns at runtime. All is working nicely but I now need to have one of
>>>> the
>>>> columns contain a TextField and not a Label. I am receiving the
>>>> following
>>>> error:
>>>>
>>>> WicketMessage: Component cell must be applied to a tag of type 'input',
>>>> not
>>>> '' (line 0, column 0)
>>>>
>>>> How can I control the markup so I may change the HTML from span to
>>>> input?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17804562.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17806187.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add a TextField in a Dynamically created DefaultDataTable

Posted by James Carman <ja...@carmanconsulting.com>.
The markup for the datatable uses <div> (or maybe span) for each
cell's item.  So, you need to give it something that it can put on a
span.  That would be a panel or fragment (as suggested).  Did you see
my earlier post about a FragmentColumn class?  It might be useful in
your case.

On Thu, Jun 12, 2008 at 12:50 PM, galbelli <ga...@apollocapital.com> wrote:
>
> Not sure I understand how to accomplish this. Even if I wrap it in a panel
> won't it be looking for markup?
>
> My current markup for the dynamic table is as follows:
>
> <html xmlns:wicket="http://wicket.apache.org/">
>
>    <head>
>        <title>Prices by Source</title>
>    </head>
>    <body>
>            <wicket:panel>
>                    <br>
>                <form wicket:id="form">
>                        Portfolio: <select wicket:id="portfolioSelect"></select>
>
>                    <table class="dataview" cellspacing="0" wicket:id="table">
>                    </table>
>
>                </form>
>            </wicket:panel>
>    </body>
> </html>
>
> And the code"
>
>
>        List<IColumn> columns = new ArrayList<IColumn>();
>
>        columns.add(new PropertyColumn(new Model("CUSIP"), "cusip",
> "cusip"));
>        columns.add(new PropertyColumn(new Model("Description"),
> "description", "description"));
>
>        PropertyColumn aPropertyColumn = new PropertyColumn(new
> Model("Override"), "overridePrice", "overridePrice")
>        {
>            public void populateItem(Item item, String componentId, IModel
> model)
>            {
>                TextField aTextField = new TextField(componentId);
>                item.add(aTextField );
>            }
>
>        };
>        columns.add(aPropertyColumn);
>
>       DefaultDataTable aDefaultDataTable = new DefaultDataTable("table",
> columns, portfolioProvider, 8);
>
>
>
>
>
>
>
>
> igor.vaynberg wrote:
>>
>> wrap the textfield in a fragment or a panel
>>
>> -igor
>>
>> On Wed, Jun 11, 2008 at 3:39 PM, galbelli <ga...@apollocapital.com>
>> wrote:
>>>
>>> I am creating a DefaultDataTable dynamically as I only know the number of
>>> columns at runtime. All is working nicely but I now need to have one of
>>> the
>>> columns contain a TextField and not a Label. I am receiving the following
>>> error:
>>>
>>> WicketMessage: Component cell must be applied to a tag of type 'input',
>>> not
>>> '' (line 0, column 0)
>>>
>>> How can I control the markup so I may change the HTML from span to input?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17804562.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add a TextField in a Dynamically created DefaultDataTable

Posted by galbelli <ga...@apollocapital.com>.
Not sure I understand how to accomplish this. Even if I wrap it in a panel
won't it be looking for markup? 

My current markup for the dynamic table is as follows: 

<html xmlns:wicket="http://wicket.apache.org/">

    <head>
        <title>Prices by Source</title>
    </head>
    <body>
	    <wicket:panel>
		    <br>
	        <form wicket:id="form">
	        	Portfolio: <select wicket:id="portfolioSelect"></select>
	        
	            <table class="dataview" cellspacing="0" wicket:id="table">
	            </table>
	             
	        </form>	    
	    </wicket:panel>
    </body>
</html>

And the code"


        List<IColumn> columns = new ArrayList<IColumn>();

        columns.add(new PropertyColumn(new Model("CUSIP"), "cusip",
"cusip"));
        columns.add(new PropertyColumn(new Model("Description"),
"description", "description"));

        PropertyColumn aPropertyColumn = new PropertyColumn(new
Model("Override"), "overridePrice", "overridePrice")
        {
            public void populateItem(Item item, String componentId, IModel
model)
            {
                TextField aTextField = new TextField(componentId);
                item.add(aTextField );
            }          
            
        };
        columns.add(aPropertyColumn);

       DefaultDataTable aDefaultDataTable = new DefaultDataTable("table",
columns, portfolioProvider, 8);








igor.vaynberg wrote:
> 
> wrap the textfield in a fragment or a panel
> 
> -igor
> 
> On Wed, Jun 11, 2008 at 3:39 PM, galbelli <ga...@apollocapital.com>
> wrote:
>>
>> I am creating a DefaultDataTable dynamically as I only know the number of
>> columns at runtime. All is working nicely but I now need to have one of
>> the
>> columns contain a TextField and not a Label. I am receiving the following
>> error:
>>
>> WicketMessage: Component cell must be applied to a tag of type 'input',
>> not
>> '' (line 0, column 0)
>>
>> How can I control the markup so I may change the HTML from span to input?
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17804562.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add a TextField in a Dynamically created DefaultDataTable

Posted by Igor Vaynberg <ig...@gmail.com>.
wrap the textfield in a fragment or a panel

-igor

On Wed, Jun 11, 2008 at 3:39 PM, galbelli <ga...@apollocapital.com> wrote:
>
> I am creating a DefaultDataTable dynamically as I only know the number of
> columns at runtime. All is working nicely but I now need to have one of the
> columns contain a TextField and not a Label. I am receiving the following
> error:
>
> WicketMessage: Component cell must be applied to a tag of type 'input', not
> '' (line 0, column 0)
>
> How can I control the markup so I may change the HTML from span to input?
> --
> View this message in context: http://www.nabble.com/How-to-add-a-TextField-in-a-Dynamically-created-DefaultDataTable-tp17788822p17788822.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org