You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Ainsley <ch...@dkib.com> on 2007/10/23 06:26:47 UTC

Newbie question - how to create a Default Data Table with onmouseover row style changes + link per row

Hi,

I'm new to Wicket but can see in principle that it is a very good approach
to the clean seperation between the presentation layer and the
model/controller layer. That said, I'm having a hard time.

I wish to create a simple table that lists the contents of a table in the
database. I have created my per-record PoJo using Ammentos as my lightweight
persistance layer. The table is now displaying successfully, but I wish to
add a per-row css-style change event + per-row link (if the user clicks
anywhere in the <tr> area, I wish to be redirected to a link corresponding
to the ID of the current row (assuming a field called keyId in my PoJo
per-row model).

Here is a snippet of sample code:


MyPanel.java

public class MyPanel extends Panel {
	public MyPanel () {
        	List<IColumn> columns = new ArrayList<IColumn> ();

		// add my columns to the column list
        
		// i implemented this fine
	        SortableDataProvider sortableDataProvider = getDataModel(status);
        
	        _dataTable = new DefaultDataTable("bondTable", columns,
sortableDataProvider, 100);
	        add(_dataTable);
	}
}


MyPanel.html

<wicket:panel>
		<table class="tablestyle1" cellspacing="0" wicket:id="myTable">
			My Table Table
		</table>
</wicket:panel>



Please can anyone give me the correct approach or tell me if this is not
possible with the DefaultDataTable component. Its very hard to know what is
possible and what is not possible in Wicket due to lack of detailed user
manual. I am currently using version 1.2.6.

If anyone can help then I will be extremely grateful.

Thanks,

Chris.
-- 
View this message in context: http://www.nabble.com/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357267
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: Newbie question - how to create a Default Data Table with onmouseover row style changes + link per row

Posted by Igor Vaynberg <ig...@gmail.com>.
On 10/22/07, Chris Ainsley <ch...@dkib.com> wrote:
>
> I started to implement this change and found that there is no IClickListener
> as part of Wicket 1.2.6. I assume this class must be part of 1.3.0 so I will
> check now. Its a shame because 1.3.0+ seems to carry with it a lot more jar
> dependencies.

1.2.6 should also have that, see the interface that Link implements.

1.3.0 has the same number of dependencies. the only difference is
dependency on slf4j rather then clogging.
>
> Also - do you have any suggestions with how to implement a per-row style +
> onmouseover changes to the row colour?

same as the other suggestion but instead of onclick also add
onmousein/out handlers that change the css style of the tr.

-igor

>
> Thanks,
>
> Chris.
>
>
> igor.vaynberg wrote:
> >
> > create a subclass of defaultdatatable, override newrowitem to be like
> > this:
> >
> > component newrowitem(...) {
> >   return new clickableitem(...) { onclick() { // implement onclick } }
> > }
> >
> > class clickableitem extends item implements iclicklistener {
> >   oncomponenttag(tag) {
> >           tag.put("onclick","window.location='"+urlfor(this,
> > iclicklistener.interface)+"';");
> >   }
> >
> >   final void onLinkClicked() { onclick(); }
> >   abstract void onclick();
> > }
> >
> > -igor
> >
> > On 10/22/07, Chris Ainsley <ch...@dkib.com> wrote:
> >>
> >> Hi,
> >>
> >> I'm new to Wicket but can see in principle that it is a very good
> >> approach
> >> to the clean seperation between the presentation layer and the
> >> model/controller layer. That said, I'm having a hard time.
> >>
> >> I wish to create a simple table that lists the contents of a table in the
> >> database. I have created my per-record PoJo using Ammentos as my
> >> lightweight
> >> persistance layer. The table is now displaying successfully, but I wish
> >> to
> >> add a per-row css-style change event + per-row link (if the user clicks
> >> anywhere in the <tr> area, I wish to be redirected to a link
> >> corresponding
> >> to the ID of the current row (assuming a field called keyId in my PoJo
> >> per-row model).
> >>
> >> Here is a snippet of sample code:
> >>
> >>
> >> MyPanel.java
> >>
> >> public class MyPanel extends Panel {
> >>         public MyPanel () {
> >>                 List<IColumn> columns = new ArrayList<IColumn> ();
> >>
> >>                 // add my columns to the column list
> >>
> >>                 // i implemented this fine
> >>                 SortableDataProvider sortableDataProvider =
> >> getDataModel(status);
> >>
> >>                 _dataTable = new DefaultDataTable("bondTable", columns,
> >> sortableDataProvider, 100);
> >>                 add(_dataTable);
> >>         }
> >> }
> >>
> >>
> >> MyPanel.html
> >>
> >> <wicket:panel>
> >>                 <table class="tablestyle1" cellspacing="0"
> >> wicket:id="myTable">
> >>                         My Table Table
> >>                 </table>
> >> </wicket:panel>
> >>
> >>
> >>
> >> Please can anyone give me the correct approach or tell me if this is not
> >> possible with the DefaultDataTable component. Its very hard to know what
> >> is
> >> possible and what is not possible in Wicket due to lack of detailed user
> >> manual. I am currently using version 1.2.6.
> >>
> >> If anyone can help then I will be extremely grateful.
> >>
> >> Thanks,
> >>
> >> Chris.
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357267
> >> 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/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357777
> 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: Newbie question - how to create a Default Data Table with onmouseover row style changes + link per row

Posted by Chris Ainsley <ch...@dkib.com>.
I started to implement this change and found that there is no IClickListener
as part of Wicket 1.2.6. I assume this class must be part of 1.3.0 so I will
check now. Its a shame because 1.3.0+ seems to carry with it a lot more jar
dependencies.

Also - do you have any suggestions with how to implement a per-row style +
onmouseover changes to the row colour?

Thanks,

Chris.


igor.vaynberg wrote:
> 
> create a subclass of defaultdatatable, override newrowitem to be like
> this:
> 
> component newrowitem(...) {
>   return new clickableitem(...) { onclick() { // implement onclick } }
> }
> 
> class clickableitem extends item implements iclicklistener {
>   oncomponenttag(tag) {
>           tag.put("onclick","window.location='"+urlfor(this,
> iclicklistener.interface)+"';");
>   }
> 
>   final void onLinkClicked() { onclick(); }
>   abstract void onclick();
> }
> 
> -igor
> 
> On 10/22/07, Chris Ainsley <ch...@dkib.com> wrote:
>>
>> Hi,
>>
>> I'm new to Wicket but can see in principle that it is a very good
>> approach
>> to the clean seperation between the presentation layer and the
>> model/controller layer. That said, I'm having a hard time.
>>
>> I wish to create a simple table that lists the contents of a table in the
>> database. I have created my per-record PoJo using Ammentos as my
>> lightweight
>> persistance layer. The table is now displaying successfully, but I wish
>> to
>> add a per-row css-style change event + per-row link (if the user clicks
>> anywhere in the <tr> area, I wish to be redirected to a link
>> corresponding
>> to the ID of the current row (assuming a field called keyId in my PoJo
>> per-row model).
>>
>> Here is a snippet of sample code:
>>
>>
>> MyPanel.java
>>
>> public class MyPanel extends Panel {
>>         public MyPanel () {
>>                 List<IColumn> columns = new ArrayList<IColumn> ();
>>
>>                 // add my columns to the column list
>>
>>                 // i implemented this fine
>>                 SortableDataProvider sortableDataProvider =
>> getDataModel(status);
>>
>>                 _dataTable = new DefaultDataTable("bondTable", columns,
>> sortableDataProvider, 100);
>>                 add(_dataTable);
>>         }
>> }
>>
>>
>> MyPanel.html
>>
>> <wicket:panel>
>>                 <table class="tablestyle1" cellspacing="0"
>> wicket:id="myTable">
>>                         My Table Table
>>                 </table>
>> </wicket:panel>
>>
>>
>>
>> Please can anyone give me the correct approach or tell me if this is not
>> possible with the DefaultDataTable component. Its very hard to know what
>> is
>> possible and what is not possible in Wicket due to lack of detailed user
>> manual. I am currently using version 1.2.6.
>>
>> If anyone can help then I will be extremely grateful.
>>
>> Thanks,
>>
>> Chris.
>> --
>> View this message in context:
>> http://www.nabble.com/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357267
>> 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/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357777
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: Newbie question - how to create a Default Data Table with onmouseover row style changes + link per row

Posted by Igor Vaynberg <ig...@gmail.com>.
create a subclass of defaultdatatable, override newrowitem to be like this:

component newrowitem(...) {
  return new clickableitem(...) { onclick() { // implement onclick } }
}

class clickableitem extends item implements iclicklistener {
  oncomponenttag(tag) {
          tag.put("onclick","window.location='"+urlfor(this,
iclicklistener.interface)+"';");
  }

  final void onLinkClicked() { onclick(); }
  abstract void onclick();
}

-igor

On 10/22/07, Chris Ainsley <ch...@dkib.com> wrote:
>
> Hi,
>
> I'm new to Wicket but can see in principle that it is a very good approach
> to the clean seperation between the presentation layer and the
> model/controller layer. That said, I'm having a hard time.
>
> I wish to create a simple table that lists the contents of a table in the
> database. I have created my per-record PoJo using Ammentos as my lightweight
> persistance layer. The table is now displaying successfully, but I wish to
> add a per-row css-style change event + per-row link (if the user clicks
> anywhere in the <tr> area, I wish to be redirected to a link corresponding
> to the ID of the current row (assuming a field called keyId in my PoJo
> per-row model).
>
> Here is a snippet of sample code:
>
>
> MyPanel.java
>
> public class MyPanel extends Panel {
>         public MyPanel () {
>                 List<IColumn> columns = new ArrayList<IColumn> ();
>
>                 // add my columns to the column list
>
>                 // i implemented this fine
>                 SortableDataProvider sortableDataProvider = getDataModel(status);
>
>                 _dataTable = new DefaultDataTable("bondTable", columns,
> sortableDataProvider, 100);
>                 add(_dataTable);
>         }
> }
>
>
> MyPanel.html
>
> <wicket:panel>
>                 <table class="tablestyle1" cellspacing="0" wicket:id="myTable">
>                         My Table Table
>                 </table>
> </wicket:panel>
>
>
>
> Please can anyone give me the correct approach or tell me if this is not
> possible with the DefaultDataTable component. Its very hard to know what is
> possible and what is not possible in Wicket due to lack of detailed user
> manual. I am currently using version 1.2.6.
>
> If anyone can help then I will be extremely grateful.
>
> Thanks,
>
> Chris.
> --
> View this message in context: http://www.nabble.com/Newbie-question---how-to-create-a-Default-Data-Table-with-onmouseover-row-style-changes-%2B-link-per-row-tf4675145.html#a13357267
> 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