wicket 如何更改导航器 css?

发布于 2024-12-01 11:28:35 字数 837 浏览 1 评论 0原文

我的应用程序中有一个导航器,我想更改他的 css:

<div wicket:id="navigator">

我如何引用他?... 并改变他的视图(css)? 有人可以给我举个例子吗?

编辑

我的目标是将我的按钮添加到导航器中......

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挥剑断情 2024-12-08 11:28:35

如果您想更改 PagingNavigator 的 html 代码,您可以创建一个扩展 PagingNavigatorMyPagingNavigator

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



}

然后您必须创建一个 >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"><<</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>

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>
黯然 2024-12-08 11:28:35

不确定您要实现什么目的,但 AttributeAppenderAttributeModifier 可用于操作给定对象的 CSS 类。

借自 Wicket Wiki< 的示例/a>:

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

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";
         }
   }
 }));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文