编辑问题以提供代码。

HTML:-

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


JAVA:

最终的PageableListView awardLinksList = new PageableListView(“ awardLinksList_”,
                AwardList,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:

最后
        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>


爪哇

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

09-03 18:12