gpt4 book ai didi

java - 在 wicket 中获取 CSS 值

转载 作者:太空宇宙 更新时间:2023-11-04 15:47:13 24 4
gpt4 key购买 nike

在我的元素中,我遇到了在 wicket 类中获取 css 属性值的问题,假设我们有一些面板

public final class ExamplePanel extends Panel {

public ExamplePanel(String id) {
super(id);
add(new Label("someText", "hello"));
}}

这个文件的html文件是

<html xmlns:wicket>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>ExamplePanel</title>
<wicket:head>
<link href="panel.css" rel="stylesheet"/>
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>

</wicket:head>
</head>
<body>
<wicket:panel>
<div id="container" wicket:id="hello">
</div>
</wicket:panel>
</body>

和下面的CSS

#parentContainer{
width:500px;
height: 500px;
background:RGB(57,51,51);
position:relative;
}

例如,我需要获取 css 代码的值

public final class ExamplePanel extends Panel {

public ExamplePanel(String id) {
super(id);
Label label = new Label("someText", "hello");
add(label);
// draft code
//String height = label.getCssValue("height");
// String position = label.getcssvalue("position");
}}

或者从这个 div 获取 css 值的任何其他解决方案?

最佳答案

由于 CSS 应用于客户端,您唯一的机会是通过 JavaScript 获取值(Torr3nt 提到的 JQuery 方法是我所知道的最简单的方法)并使用 Ajax 将这些值发布回您的应用程序.

有关于如何从 JavaScript 调用 wicket 的描述 here .

关于java - 在 wicket 中获取 CSS 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11607039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com