gpt4 book ai didi

java - 使用 PageableListView 填充链接和部分时如何添加 anchor 链接?如何获取我的链接应指向的 "id"?

转载 作者:行者123 更新时间:2023-12-02 13:39:17 41 4
gpt4 key购买 nike

编辑问题以提供代码。

HTML:-

<a href=""><div wicket:id="awardLink_"></div></a>

JAVA:

最终PageableListView AwardLinksList = new PageableListView("awardLinksList_", 获奖名单,10) {

        private static final long serialVersionUID = 1L;

@SuppressWarnings({ "serial", "unchecked", "unchecked" })
@Override
protected void populateItem(ListItem item) {
final BLL_Docs StkList = (BLL_Docs) item
.getModelObject();
item.add(new Label("awardLink_",StkList.getAwardName()==null?"NA":StkList.getAwardName()));
}

};

以上代码将提供 4-5 个奖项列表,这些列表将使用 pageablelistview 生成例如:Bharat Ratna、Padma Bhushan、Padma Vibhushan。

每个奖项的描述将通过

生成

HTML:-

<div wicket:id="lblFarmerBio" class="control-label2"></div>

JAVA:

final PageableListView awdDisplay = new PageableListView("listView_", ImgList, 10) {

        private static final long serialVersionUID = 1L;

@SuppressWarnings({ "serial", "unchecked", "unchecked" })
@Override
protected void populateItem(ListItem item) {
final BLL_Docs StkList = (BLL_Docs) item
.getModelObject();

item.add(new Label("lblFarmerBio",StkList.getFarmerBio()==null?"NA":StkList.getFarmerBio()));

}

};

当我点击链接 Bharat Ratna 时,它应该关注提供 Bharat Ratna 描述的部分。

最佳答案

由于您没有提供任何代码片段,因此无法产生所需的输出。

以下是一些建议:

您需要的是onclick您应该指向该部分的链接

<a href="#section1" wicket:id="sectionLink">Go my section  div</a>

<div id="section1" wicket:id="section"> Focus here on click with the respected link id reference</div>

Java

   // It just reference object
private class DataObject implements Serializable{
private String link;
private String section;
// getter & setter , constructor
}


List<DataObject> dataObjectList = new ArrayList<>();
dataObjectList.add(new DataObject("section1","Section1 with a description"));
dataObjectList.add(new DataObject("section2","Section2 with a description"));
dataObjectList.add(new DataObject("section3","Section3 with a description"));
dataObjectList.add(new DataObject("section4","Section4 with a description"));

ListView<DataObject> pageableListView = new PageableListView("Lists",dataObjectList,20) {
@Override
protected void populateItem(ListItem listItem) {
DataObject dataObject = (DataObject) listItem.getModelObject();
//WebComponent or WebMarkupContainer either you can use
WebMarkupContainer sectionLink = new WebMarkupContainer("sectionLink");
sectionLink.add(new AttributeModifier("href","#"+dataObject.getLink()));
listItem.add(sectionLink);
Label sectionPart = new Label("section",dataObject.getSection());
sectionPart.add(new AttributeModifier("id",listItem.getIndex()));
listItem.add(sectionPart);

}
};
add(pageableListView);

关于java - 使用 PageableListView 填充链接和部分时如何添加 anchor 链接?如何获取我的链接应指向的 "id"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42827643/

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