How can we make Dynamic Table Column Name Header title in 2 lines? - wicket

I am creating dynamic table using AbstractColumn.
I needs to display column title in 2 line.
Is it possible in wicket?
Ex: My column header is "Add/Edit Team Leads"
I want it in "Add/Edit \n Team Leads"
\n is not working here.
Please help.

Override #getHeader(String) to return a MultiLineLabel:
#Override
public Component getHeader(final String componentId)
{
return new MultiLineLabel(componentId, getDisplayModel());
}

Related

How to I update property table reffered in mybatis

Strange I couldn't find this easy answer in stackoverflow or mybatis guide. Thank you for those who is trying to help.
I have a class like this
Class One {
String name;
}
Class Two {
String name2;
One one;
}
I am using MyBatis #Update annotaion.
#Update("UPDATE One SET " +
"name=#{name}")
int updatefirst(Two two);
#Update("UPDATE Two SET " +
"name2=#{name}")
int updatesecondname(Two two);
How do I include the inner property that updates the foreign table one from the above query when I call updatesecondname?
Any help greatly appreciated.

How to get the column name in nattable?

I had create an example like Editor Example, while the difference is that my demo can hide column. While when I hidden some column, I can not the collect selected column index, I changed my mind, I want to get the selected column's header name. How to get it?
Following is the handler to handle the selected column
But I don't know how to get the column name
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellSelectionEvent) {
CellSelectionEvent cellEvent = (CellSelectionEvent) event;
int columnIndex = natTable.getColumnIndexByPosition(cellEvent.getColumnPosition());
SelectionLayer selectionLayer = cellEvent.getSelectionLayer();
........
}
You need the reference to the ColumnHeaderLayer and get the data value. E.g. ColumnHeaderLayer#getDataValueByPosition(int, int)

gxt GridInlineEditing doesn't notify data change in ListStore when the user completeEdit

Actually I am using GWT with gxt (3.1) framework. I want to create an editable grid.
So I write the code :
List<ColumnConfig<String[], ?>> l = createColumnList(cols);
gridDataDisplay = new Grid<String[]>(store, new ColumnModel<String[]>(l));
int indice = 0;
final GridEditing<String[]> editing = new GridInlineEditing<String[]>(gridDataDisplay);
for(ColumnConfig<String[], ?> columnConfig : l) {
if (!notEditable.contains(indice)) {
ColumnConfig<String[], String> tempColumnConfig = (ColumnConfig<String[], String>) columnConfig;
editing.addEditor(tempColumnConfig, new TextField());
}
indice++;
}
So I follow the tutorial Grid Editing.
With the code below, I can modify my data by click on the column cell. But when validate : the change don't appear on my table. The Grid dislay the old value until call store.commitChanges();
Thank you in advance for your help.
Finally, I found out what is the problem. I guess it will help other people.
When, I created my ListStore, I use a keyProvider an integer that I increment every time I add a new record.
Apparently, the key keyProvider must use only the model attribute.

GWT column sort handler ,how to get column's value which has been selected

I have a celltable in GWT and want to implement sorting functionality on it , from database(Criteria)
for that i just want to know how to get the value of the column which has been clicked for sorting
here is my code
ctJobs.addColumnSortHandler(new ColumnSortEvent.Handler() {
public void onColumnSort(ColumnSortEvent event) {
event.getColumn();
event.getColumn().getValue("what do we need to write here ???");
from event.getColumn() , i am getting column in the form of object
com.google.gwt.cell.client.ClickableTextCell#188a12e
I want to know the the column's name / value
for that i am trying event.getcolumn().getvalue("??");
but what is the parameter for that, or is there any other way of getting column's name which has been clicked.
Thanks
Are you using a ListDataProvider or an AsyncDataProvider for your cell table?
In case of an AsyncDataProvider the sorting must be done on the server side, so there is no need to add a ColumnSortHandler.
Please see the GWT docs.
To get the name of the column clicked for sorting see this question.
When creating the table columns, set the dataStoreName of the column.
column.setDataStoreName("columnX");
Next, when in the AsyncDataProvider get the sort history of the clicked headers like the following
final AsyncDataProvider<SQLRow> dataProvider = new AsyncDataProvider<SQLRow>(){
#Override
protected void onRangeChanged(HasData<SQLRow> display) {
for (int i=0;i<sortList.size();i++) {
sortList.get(i).getColumn().getDataStoreName();
}
}
}

Turn links in wicket panels to hyperlinks

I'm trying to find a way to automatically convert links in a panel to hyper-links. So for example a user input is:
"And here you can find my awesome example: http://example.com"
Is it possible in wicket to add an anchor element to each "http://..." text, so the above example would output
"And here you can find my awesome example: http://example.com"
instead?
You can use Wicket's built in SmartLinkLabel.
From the Javadoc:
If you have email addresses or web URLs in the data that you are displaying, then you can automatically display those pieces of data as hyperlinks, you will not have to take any action to convert that data.
One way to do this is to extend Label and override onComponentTagBody
Something like:
public class AnchorizeLabel extends Label {
public AnchorizeLabel(String id, String body) {
super(id, body);
}
#Override
protected void onComponentTagBody(MarkupStream stream, ComponentTag tag) {
String newBody = createAnchors(getDefaultModelObjectAsString());
replaceComponentTagBody(stream, tag, newBody);
}
private String createAnchors(String body) {
// regex magic to create links
}
}
You can also accomplish this with a custom IModel or IConverter but I prefer the Label approach.