Wicket 6 IColumn How the name can be of type other than string?

余生颓废 提交于 2019-12-07 23:59:34

问题


Interface IColumn contains a method getSortProperty(), which returns a value of any type S. How the name can be of type other than string?

    /**
     * Returns the name of the property that this header sorts. If null is returned the header will
     * be unsortable.
     * 
     * @return the sort property
     */

S getSortProperty();

http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.html

In wicket older version 6:

PropertyColumn<SomeClass> column = new PropertyColumn(Model.of("Header"), "sortProperty", "propertyExpression"); 

Wicket 6: description:

PropertyColumn(IModel<String> displayModel, S sortProperty, String propertyExpression);

example:

PropertyColumn<SomeClass, Long> column = new PropertyColumn(Model.of("Header"), ?, "propertyExpression"); 

what to write on the ground "?"


回答1:


In your example using a PropertyColumn<SomeClass, Long> you have to use a Long value as the second parameter, as this is the type of the sort property.

If your sort property is a String, simply use PropertyColumn<SomeClass, String> and pass your property to the constructor.




回答2:


javadoc at http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.html says

getSortProperty

java.lang.String getSortProperty()

    Returns the name of the property that this header sorts. If null is returned the header will be unsortable.

    Returns:
        a string representing the sort property


来源:https://stackoverflow.com/questions/13864075/wicket-6-icolumn-how-the-name-can-be-of-type-other-than-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!