简体   繁体   English

wicket如何更改导航器的css?

[英]wicket how to change navigator css?

I have a navigator in my application which I want to change his css : 我的应用程序中有一个导航器,我想更改他的css:

<div wicket:id="navigator">

how can I refrence to him ?... and change his view(css) ? 我怎么能尊重他?...并改变他的观点(css)? can anyone please reference me to an example ? 有人可以参考我的例子吗?

EDIT 编辑

my goal 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 : 如果要更改PagingNavigator的html代码,可以创建MyPagingNavigator ,它扩展了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 . 然后,您必须创建一个MyPagingNavigator.html ,您可以在其中进行更改 But be sure that you dont remove any components from MyPagingNavigator.html (referenced with wicket:id=) 但是请确保不要从MyPagingNavigator.html中删除任何组件(用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): 您可以使用检票口来源(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>

Not sure what you're trying to accomplish, but AttributeAppender and AttributeModifier can be used to manipulate the CSS class of a given object. 不确定您要完成什么,但是AttributeAppenderAttributeModifier可以用于操作给定对象的CSS类。

Example borrowed from the Wicket Wiki : Wicket Wiki借来的示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM