I have a navigator in my application which I want to change his css :
<div wicket:id="navigator">
how can I refrence to him ?... and change his view(css) ? can anyone please reference me to an example ?
EDIT
my go开发者_运维百科al is to add my buttones to the navigator ...
<table cellspacing="0" class="dataview" >
<tbody>
<thead>
<tr>
<th>Name</th>
<th>password</th>
<th>Delete</th>
</tr>
</thead>
<tr wicket:id="simple" >
<td><span wicket:id="name">Test ID</span></td>
<td><span wicket:id="password">Test ID</span></td>
<td><a href="#" wicket:id="deleteLink" class="button"></a></td>
</tr>
</tbody>
</table>
<div wicket:id="navigator">
If you want to change the html-code of the PagingNavigator
you can create a MyPagingNavigator
which extends PagingNavigator
:
import org.apache.wicket.markup.html.navigation.paging.IPageable;
import org.apache.wicket.markup.html.navigation.paging.IPagingLabelProvider;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
class MyPagingNavigator extends PagingNavigator {
public MyPagingNavigator(String id, IPageable pageable) {
super(id, pageable);
}
public MyPagingNavigator(String id, IPageable pageable, IPagingLabelProvider labelProvider) {
super(id, pageable, labelProvider);
}
}
Then you have to create a MyPagingNavigator.html
where you can make your changes. But be sure that you dont remove any components from MyPagingNavigator.html (referenced with wicket:id=)
You can use the original content from the wicket source (src/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.html):
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html xmlns:wicket>
<body>
<wicket:panel>
<a wicket:id="first"><<</a> <a wicket:id="prev"><</a>
<span wicket:id="navigation">
<a wicket:id="pageLink" href="#"><span wicket:id="pageNumber">5</span></a>
</span>
<a wicket:id="next">></a> <a wicket:id="last">>></a>
</wicket:panel>
</body>
</html>
Not sure what you're trying to accomplish, but AttributeAppender
and AttributeModifier
can be used to manipulate the CSS class of a given object.
Example borrowed from the Wicket Wiki:
label.add(new AttributeModifier("class", new Model() {
public Object getObject(final Component component) {
if ( test.getAlarmState() )
return "alarm";
} else {
return "noAlarm";
}
}
}));
精彩评论