单击Ajaxlink时,我需要显示JSON文件中的数据。我实现了以下代码,该代码无法正常工作。如果我有任何错误,请更正我的代码。 (是否可以在AjaxLink中添加标签)
谢谢。
AjaxLink<Void> jsonData = new AjaxLink<Void>("jsonData") {
@Override
public void onClick(AjaxRequestTarget target) {
File jsonFile;
try {
jsonFile = new File(fileLocation);
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readValue(jsonFile, JsonNode.class);
Label jsonLabel = new Label("jsonLabel",
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode));
jsonLabel.setOutputMarkupId(true);
jsonLabel.setOutputMarkupPlaceholderTag(true);
target.add(jsonLabel);
addOrReplace(jsonLabel);
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
};
add(jsonData);
HTML:
<div>
<a wicket:id="jsonData" class="text-white">View Template</a>
<pre wicket:id="jsonLabel" class="text-white bg-dark"> </pre>
</div>
答案 0 :(得分:1)
您需要将Label添加为AjaxLink的兄弟姐妹:
let shapeLayer = CAShapeLayer()
shapeLayer.path = UIBezierPath(roundedRect: tipView.bounds, byRoundingCorners: [.topLeft, .bottomLeft, .bottomRight], cornerRadii: CGSize(width: 20, height: 20)).cgPath
shapeLayer.fillColor = UIColor.darkGray.cgColor
shapeLayer.masksToBounds = false
shapeLayer.shadowColor = UIColor.darkGray.cgColor
shapeLayer.shadowPath = shapeLayer.path
shapeLayer.shadowOffset = CGSize(width: 0, height: 2)
shapeLayer.shadowOpacity = 0.5
shapeLayer.shadowRadius = 2.0
tipView.layer.insertSublayer(shapeLayer, at: 0)
您的HTML没问题。