2011-08-27 27 views
2

我在我的应用程序导航,我想改变自己的CSS:wicket如何更改导航器的CSS?

<div wicket:id="navigator"> 

我怎么能refrence他...... 并改变他的看法(CSS)? 任何人都可以请参考我的例子?

编辑

我的目标是我的buttones添加到导航...

<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"> 
+0

代码里面的表与导航无关,但与dataview相关。我不明白你想达到什么。 –

+0

做了关于扩展PagingNavigator工作的答案吗? –

回答

3

如果你想改变PagingNavigator的HTML代码,你可以创建扩展PagingNavigator一个MyPagingNavigator

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); 
    } 



} 

然后,你必须创建a MyPagingNavigator.html您可以在其中进行更改。但请确保您不会从MyPagingNavigator.html中删除任何组件(引用了wicket:id =)

您可以使用来自wicket源的原始内容(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">&lt;&lt;</a>&nbsp;<a wicket:id="prev">&lt;</a> 
    <span wicket:id="navigation"> 
      <a wicket:id="pageLink" href="#"><span wicket:id="pageNumber">5</span></a> 
    </span> 
    <a wicket:id="next">&gt;</a>&nbsp;<a wicket:id="last">&gt;&gt;</a> 
    </wicket:panel> 
</body> 
</html> 
0

不知道你想要什么来完成,但AttributeAppenderAttributeModifier可以用来操纵给定对象的CSS类。

例如,从Wicket Wiki借:

label.add(new AttributeModifier("class", new Model() { 
    public Object getObject(final Component component) { 
     if (test.getAlarmState()) 
      return "alarm"; 
     } else { 
      return "noAlarm"; 
     } 
    } 
}));