You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ganea iulia <su...@gmail.com> on 2017/03/16 08:58:09 UTC

ListView color background lineitem dinamically not working

Hello,

I have a listview and I want to dinamically color some of the rows (items).
But it is not working, nothing gets colored when it should.

*Here is the markup:*
<tbody wicket:id="itemsContainer">
<wicket:container wicket:id="forEachItem">
<tr>
<td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
<td wicket:id="item1">[item1]</td>
<td wicket:id="item2">[item2]</td>
<td wicket:id="item3">[item3]</td>
<td wicket:id="item4">[item4]</td>
<td wicket:id="item5">[item5]</td>
<td wicket:id="item6">[item6]</td>
<td wicket:id="item7">[item7]</td>
<td wicket:id="item8">[item8]</td>
<td wicket:id="item9">[item9]</td>
<td wicket:id="item10">[item10]</td>
</tr>
<tr>
<td colspan="11" align="center" style="border-bottom: thin solid
gray;"><textarea wicket:id="itemArea" rows="3"
cols="100">Area</textarea></td>
</tr>
 </wicket:container>
</tbody>
</table>

*Here is the code:*

@Override
protected ListItem<Items> newItem(final int index, IModel<Items> model) {
return new ListItem<Items>(index, getListItemModel(getModel(), index)) {

@Override
protected void onComponentTag(final ComponentTag tag) {
Items line = getModelObject();
if (line.getIdLn() == 6)
tag.put("style", "background-color:green");
else if (line.getIdLn() == 4 )
tag.put("style", "background-color:red");

// continue with default behavior
super.onComponentTag(tag);

}
};
}

Could you please advise?

Re: ListView color background lineitem dinamically not working

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

The problem is at:
<wicket:container wicket:id="forEachItem">
<tr>

You need the <tr> to be Wicket component.
<wicket:container> is not rendered at Production mode.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Mar 16, 2017 at 9:58 AM, ganea iulia <su...@gmail.com> wrote:

> Hello,
>
> I have a listview and I want to dinamically color some of the rows (items).
> But it is not working, nothing gets colored when it should.
>
> *Here is the markup:*
> <tbody wicket:id="itemsContainer">
> <wicket:container wicket:id="forEachItem">
> <tr>
> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
> <td wicket:id="item1">[item1]</td>
> <td wicket:id="item2">[item2]</td>
> <td wicket:id="item3">[item3]</td>
> <td wicket:id="item4">[item4]</td>
> <td wicket:id="item5">[item5]</td>
> <td wicket:id="item6">[item6]</td>
> <td wicket:id="item7">[item7]</td>
> <td wicket:id="item8">[item8]</td>
> <td wicket:id="item9">[item9]</td>
> <td wicket:id="item10">[item10]</td>
> </tr>
> <tr>
> <td colspan="11" align="center" style="border-bottom: thin solid
> gray;"><textarea wicket:id="itemArea" rows="3"
> cols="100">Area</textarea></td>
> </tr>
>  </wicket:container>
> </tbody>
> </table>
>
> *Here is the code:*
>
> @Override
> protected ListItem<Items> newItem(final int index, IModel<Items> model) {
> return new ListItem<Items>(index, getListItemModel(getModel(), index)) {
>
> @Override
> protected void onComponentTag(final ComponentTag tag) {
> Items line = getModelObject();
> if (line.getIdLn() == 6)
> tag.put("style", "background-color:green");
> else if (line.getIdLn() == 4 )
> tag.put("style", "background-color:red");
>
> // continue with default behavior
> super.onComponentTag(tag);
>
> }
> };
> }
>
> Could you please advise?
>

Re: ListView color background lineitem dinamically not working

Posted by ganea iulia <su...@gmail.com>.
Thank you, it's great!

On Thu, Mar 16, 2017 at 1:05 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> you'll have to add two MarkupContainers and style both <tr>:
>
>   <tbody wicket:id="itemsContainer">
>     <wicket:container wicket:id="forEachItem">
>       <tr wicket:id="firstRow">...</tr>
>       <tr wicket:id="secondRow">...</tr>
>
>
>   protected void populateItem(ListItem item) {
>     WebMarkupContainer firstRow = new WebMarkupContainer("firstRow") {
>       @Override
>       protected void onComponentTag(final ComponentTag tag) {
>       Items line = item.getModelObject();
>       if (line.getIdLn() == 6)
>         tag.put("style", "background-color:green");
>       else if (line.getIdLn() == 4 )
>         tag.put("style", "background-color:red");
>
>       // continue with default behavior
>       super.onComponentTag(tag);
>     };
>     item.add(firstRow);
>
>     firstRow.add(...
>
>     WebMarkupContainer secondRow = ...;
>   }
>
> Best regards
> Sven
>
>
> On 16.03.2017 11:39, ganea iulia wrote:
>
>> Thank you so much for you explanation.
>> I had to put the two <tr> inside the <wicket:container> because I need to
>> repeat every two rows.
>> Do you have any hint on how to do it and still be able to change the
>> color?
>>
>>
>>
>> On Thu, Mar 16, 2017 at 12:36 PM, ganea iulia <su...@gmail.com>
>> wrote:
>>
>> Thank you so much for you explanation.
>>> I had to put the two <tr> inside the <wicket:container> because I need to
>>> repeat every two rows.
>>>
>>>
>>>
>>> On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi,
>>>>
>>>> it seems your ListView is bound to the <wicket:container
>>>> wicket:id="forEachItem"> tag, which cannot be styled.
>>>>
>>>> Change your markup to:
>>>>
>>>>    <tbody wicket:id="itemsContainer">
>>>>      <tr wicket:id="forEachItem">
>>>>
>>>> Have fun
>>>> Sven
>>>>
>>>>
>>>> On 16.03.2017 09:58, ganea iulia wrote:
>>>>
>>>> Hello,
>>>>>
>>>>> I have a listview and I want to dinamically color some of the rows
>>>>> (items).
>>>>> But it is not working, nothing gets colored when it should.
>>>>>
>>>>> *Here is the markup:*
>>>>> <tbody wicket:id="itemsContainer">
>>>>> <wicket:container wicket:id="forEachItem">
>>>>> <tr>
>>>>> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
>>>>> <td wicket:id="item1">[item1]</td>
>>>>> <td wicket:id="item2">[item2]</td>
>>>>> <td wicket:id="item3">[item3]</td>
>>>>> <td wicket:id="item4">[item4]</td>
>>>>> <td wicket:id="item5">[item5]</td>
>>>>> <td wicket:id="item6">[item6]</td>
>>>>> <td wicket:id="item7">[item7]</td>
>>>>> <td wicket:id="item8">[item8]</td>
>>>>> <td wicket:id="item9">[item9]</td>
>>>>> <td wicket:id="item10">[item10]</td>
>>>>> </tr>
>>>>> <tr>
>>>>> <td colspan="11" align="center" style="border-bottom: thin solid
>>>>> gray;"><textarea wicket:id="itemArea" rows="3"
>>>>> cols="100">Area</textarea></td>
>>>>> </tr>
>>>>>    </wicket:container>
>>>>> </tbody>
>>>>> </table>
>>>>>
>>>>> *Here is the code:*
>>>>>
>>>>> @Override
>>>>> protected ListItem<Items> newItem(final int index, IModel<Items>
>>>>> model) {
>>>>> return new ListItem<Items>(index, getListItemModel(getModel(), index))
>>>>> {
>>>>>
>>>>> @Override
>>>>> protected void onComponentTag(final ComponentTag tag) {
>>>>> Items line = getModelObject();
>>>>> if (line.getIdLn() == 6)
>>>>> tag.put("style", "background-color:green");
>>>>> else if (line.getIdLn() == 4 )
>>>>> tag.put("style", "background-color:red");
>>>>>
>>>>> // continue with default behavior
>>>>> super.onComponentTag(tag);
>>>>>
>>>>> }
>>>>> };
>>>>> }
>>>>>
>>>>> Could you please advise?
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>> 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: ListView color background lineitem dinamically not working

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you'll have to add two MarkupContainers and style both <tr>:

   <tbody wicket:id="itemsContainer">
     <wicket:container wicket:id="forEachItem">
       <tr wicket:id="firstRow">...</tr>
       <tr wicket:id="secondRow">...</tr>


   protected void populateItem(ListItem item) {
     WebMarkupContainer firstRow = new WebMarkupContainer("firstRow") {
       @Override
       protected void onComponentTag(final ComponentTag tag) {
       Items line = item.getModelObject();
       if (line.getIdLn() == 6)
         tag.put("style", "background-color:green");
       else if (line.getIdLn() == 4 )
         tag.put("style", "background-color:red");

       // continue with default behavior
       super.onComponentTag(tag);
     };
     item.add(firstRow);

     firstRow.add(...

     WebMarkupContainer secondRow = ...;
   }

Best regards
Sven

On 16.03.2017 11:39, ganea iulia wrote:
> Thank you so much for you explanation.
> I had to put the two <tr> inside the <wicket:container> because I need to
> repeat every two rows.
> Do you have any hint on how to do it and still be able to change the color?
>
>
>
> On Thu, Mar 16, 2017 at 12:36 PM, ganea iulia <su...@gmail.com>
> wrote:
>
>> Thank you so much for you explanation.
>> I had to put the two <tr> inside the <wicket:container> because I need to
>> repeat every two rows.
>>
>>
>>
>> On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier <sv...@meiers.net> wrote:
>>
>>> Hi,
>>>
>>> it seems your ListView is bound to the <wicket:container
>>> wicket:id="forEachItem"> tag, which cannot be styled.
>>>
>>> Change your markup to:
>>>
>>>    <tbody wicket:id="itemsContainer">
>>>      <tr wicket:id="forEachItem">
>>>
>>> Have fun
>>> Sven
>>>
>>>
>>> On 16.03.2017 09:58, ganea iulia wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a listview and I want to dinamically color some of the rows
>>>> (items).
>>>> But it is not working, nothing gets colored when it should.
>>>>
>>>> *Here is the markup:*
>>>> <tbody wicket:id="itemsContainer">
>>>> <wicket:container wicket:id="forEachItem">
>>>> <tr>
>>>> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
>>>> <td wicket:id="item1">[item1]</td>
>>>> <td wicket:id="item2">[item2]</td>
>>>> <td wicket:id="item3">[item3]</td>
>>>> <td wicket:id="item4">[item4]</td>
>>>> <td wicket:id="item5">[item5]</td>
>>>> <td wicket:id="item6">[item6]</td>
>>>> <td wicket:id="item7">[item7]</td>
>>>> <td wicket:id="item8">[item8]</td>
>>>> <td wicket:id="item9">[item9]</td>
>>>> <td wicket:id="item10">[item10]</td>
>>>> </tr>
>>>> <tr>
>>>> <td colspan="11" align="center" style="border-bottom: thin solid
>>>> gray;"><textarea wicket:id="itemArea" rows="3"
>>>> cols="100">Area</textarea></td>
>>>> </tr>
>>>>    </wicket:container>
>>>> </tbody>
>>>> </table>
>>>>
>>>> *Here is the code:*
>>>>
>>>> @Override
>>>> protected ListItem<Items> newItem(final int index, IModel<Items> model) {
>>>> return new ListItem<Items>(index, getListItemModel(getModel(), index)) {
>>>>
>>>> @Override
>>>> protected void onComponentTag(final ComponentTag tag) {
>>>> Items line = getModelObject();
>>>> if (line.getIdLn() == 6)
>>>> tag.put("style", "background-color:green");
>>>> else if (line.getIdLn() == 4 )
>>>> tag.put("style", "background-color:red");
>>>>
>>>> // continue with default behavior
>>>> super.onComponentTag(tag);
>>>>
>>>> }
>>>> };
>>>> }
>>>>
>>>> Could you please advise?
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> 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: ListView color background lineitem dinamically not working

Posted by ganea iulia <su...@gmail.com>.
Thank you so much for you explanation.
I had to put the two <tr> inside the <wicket:container> because I need to
repeat every two rows.
Do you have any hint on how to do it and still be able to change the color?



On Thu, Mar 16, 2017 at 12:36 PM, ganea iulia <su...@gmail.com>
wrote:

> Thank you so much for you explanation.
> I had to put the two <tr> inside the <wicket:container> because I need to
> repeat every two rows.
>
>
>
> On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi,
>>
>> it seems your ListView is bound to the <wicket:container
>> wicket:id="forEachItem"> tag, which cannot be styled.
>>
>> Change your markup to:
>>
>>   <tbody wicket:id="itemsContainer">
>>     <tr wicket:id="forEachItem">
>>
>> Have fun
>> Sven
>>
>>
>> On 16.03.2017 09:58, ganea iulia wrote:
>>
>>> Hello,
>>>
>>> I have a listview and I want to dinamically color some of the rows
>>> (items).
>>> But it is not working, nothing gets colored when it should.
>>>
>>> *Here is the markup:*
>>> <tbody wicket:id="itemsContainer">
>>> <wicket:container wicket:id="forEachItem">
>>> <tr>
>>> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
>>> <td wicket:id="item1">[item1]</td>
>>> <td wicket:id="item2">[item2]</td>
>>> <td wicket:id="item3">[item3]</td>
>>> <td wicket:id="item4">[item4]</td>
>>> <td wicket:id="item5">[item5]</td>
>>> <td wicket:id="item6">[item6]</td>
>>> <td wicket:id="item7">[item7]</td>
>>> <td wicket:id="item8">[item8]</td>
>>> <td wicket:id="item9">[item9]</td>
>>> <td wicket:id="item10">[item10]</td>
>>> </tr>
>>> <tr>
>>> <td colspan="11" align="center" style="border-bottom: thin solid
>>> gray;"><textarea wicket:id="itemArea" rows="3"
>>> cols="100">Area</textarea></td>
>>> </tr>
>>>   </wicket:container>
>>> </tbody>
>>> </table>
>>>
>>> *Here is the code:*
>>>
>>> @Override
>>> protected ListItem<Items> newItem(final int index, IModel<Items> model) {
>>> return new ListItem<Items>(index, getListItemModel(getModel(), index)) {
>>>
>>> @Override
>>> protected void onComponentTag(final ComponentTag tag) {
>>> Items line = getModelObject();
>>> if (line.getIdLn() == 6)
>>> tag.put("style", "background-color:green");
>>> else if (line.getIdLn() == 4 )
>>> tag.put("style", "background-color:red");
>>>
>>> // continue with default behavior
>>> super.onComponentTag(tag);
>>>
>>> }
>>> };
>>> }
>>>
>>> Could you please advise?
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: ListView color background lineitem dinamically not working

Posted by ganea iulia <su...@gmail.com>.
Thank you so much for you explanation.
I had to put the two <tr> inside the <wicket:container> because I need to
repeat every two rows.



On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> it seems your ListView is bound to the <wicket:container
> wicket:id="forEachItem"> tag, which cannot be styled.
>
> Change your markup to:
>
>   <tbody wicket:id="itemsContainer">
>     <tr wicket:id="forEachItem">
>
> Have fun
> Sven
>
>
> On 16.03.2017 09:58, ganea iulia wrote:
>
>> Hello,
>>
>> I have a listview and I want to dinamically color some of the rows
>> (items).
>> But it is not working, nothing gets colored when it should.
>>
>> *Here is the markup:*
>> <tbody wicket:id="itemsContainer">
>> <wicket:container wicket:id="forEachItem">
>> <tr>
>> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
>> <td wicket:id="item1">[item1]</td>
>> <td wicket:id="item2">[item2]</td>
>> <td wicket:id="item3">[item3]</td>
>> <td wicket:id="item4">[item4]</td>
>> <td wicket:id="item5">[item5]</td>
>> <td wicket:id="item6">[item6]</td>
>> <td wicket:id="item7">[item7]</td>
>> <td wicket:id="item8">[item8]</td>
>> <td wicket:id="item9">[item9]</td>
>> <td wicket:id="item10">[item10]</td>
>> </tr>
>> <tr>
>> <td colspan="11" align="center" style="border-bottom: thin solid
>> gray;"><textarea wicket:id="itemArea" rows="3"
>> cols="100">Area</textarea></td>
>> </tr>
>>   </wicket:container>
>> </tbody>
>> </table>
>>
>> *Here is the code:*
>>
>> @Override
>> protected ListItem<Items> newItem(final int index, IModel<Items> model) {
>> return new ListItem<Items>(index, getListItemModel(getModel(), index)) {
>>
>> @Override
>> protected void onComponentTag(final ComponentTag tag) {
>> Items line = getModelObject();
>> if (line.getIdLn() == 6)
>> tag.put("style", "background-color:green");
>> else if (line.getIdLn() == 4 )
>> tag.put("style", "background-color:red");
>>
>> // continue with default behavior
>> super.onComponentTag(tag);
>>
>> }
>> };
>> }
>>
>> Could you please advise?
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: ListView color background lineitem dinamically not working

Posted by Sven Meier <sv...@meiers.net>.
Hi,

it seems your ListView is bound to the <wicket:container 
wicket:id="forEachItem"> tag, which cannot be styled.

Change your markup to:

   <tbody wicket:id="itemsContainer">
     <tr wicket:id="forEachItem">

Have fun
Sven


On 16.03.2017 09:58, ganea iulia wrote:
> Hello,
>
> I have a listview and I want to dinamically color some of the rows (items).
> But it is not working, nothing gets colored when it should.
>
> *Here is the markup:*
> <tbody wicket:id="itemsContainer">
> <wicket:container wicket:id="forEachItem">
> <tr>
> <td rowspan="2"><input type="checkbox" wicket:id="itemCheck" /></td>
> <td wicket:id="item1">[item1]</td>
> <td wicket:id="item2">[item2]</td>
> <td wicket:id="item3">[item3]</td>
> <td wicket:id="item4">[item4]</td>
> <td wicket:id="item5">[item5]</td>
> <td wicket:id="item6">[item6]</td>
> <td wicket:id="item7">[item7]</td>
> <td wicket:id="item8">[item8]</td>
> <td wicket:id="item9">[item9]</td>
> <td wicket:id="item10">[item10]</td>
> </tr>
> <tr>
> <td colspan="11" align="center" style="border-bottom: thin solid
> gray;"><textarea wicket:id="itemArea" rows="3"
> cols="100">Area</textarea></td>
> </tr>
>   </wicket:container>
> </tbody>
> </table>
>
> *Here is the code:*
>
> @Override
> protected ListItem<Items> newItem(final int index, IModel<Items> model) {
> return new ListItem<Items>(index, getListItemModel(getModel(), index)) {
>
> @Override
> protected void onComponentTag(final ComponentTag tag) {
> Items line = getModelObject();
> if (line.getIdLn() == 6)
> tag.put("style", "background-color:green");
> else if (line.getIdLn() == 4 )
> tag.put("style", "background-color:red");
>
> // continue with default behavior
> super.onComponentTag(tag);
>
> }
> };
> }
>
> Could you please advise?
>


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