Enable selection and Get selected marker value from dvt:thematicMap in ADF Faces

Sharing is Caring

Hello All
Previously I have posted about using dvt:thematicMap to mark locations using latitude and longitude, In that post, I have described showing different cities as markers on a world map using a POJO based data structure for dvt:thematicMap in ADF Faces. Now In this post, I am going to describe that how can we enable selection in the thematic map and get selected location value in managed bean so here in this post I am extending that previous application


dvt:thematicMap looks like this after pointing cities markers

Now to enable selection set selection mode to single for dvt:pointDataLayer and create a selection listener method in managed bean

 

Now bind dvt:pointDataLayer to bean (Create component binding in Managed Bean)

    private UIPointDataLayer dataLayerBind;

public void setDataLayerBind(UIPointDataLayer dataLayerBind) {
this.dataLayerBind = dataLayerBind;
}

public UIPointDataLayer getDataLayerBind() {
return dataLayerBind;
}

See the generated XML of dvt:thematicMap

<dvt:thematicMap basemap="world" id="tm1" summary="World Map" styleClass="AFStretchWidth"
                                     partialTriggers="::b1" inlineStyle="background-color:#e9ffdc;">
                        <dvt:areaLayer layer="continents" id="al2">
                            <dvt:pointDataLayer id="dl1" value="#{viewScope.MapBean.mapDetail}" var="row"
                                                selectionMode="single"
                                                selectionListener="#{viewScope.MapBean.mapSelectionListener}"
                                                binding="#{viewScope.MapBean.dataLayerBind}">
                                <dvt:pointLocation id="pl1" type="pointXY" pointY="#{row.lattitude}"
                                                   pointX="#{row.longitude}">
                                    <dvt:marker id="m1" shortDesc="#{row.textDisp}" fillColor="#ff0000"
                                                borderWidth="1.0" scaleX="2.0" scaleY="2.0" labelDisplay="on"
                                                labelPosition="bottom" shape="triangleDown" value="#{row.location}"
                                                labelStyle="color:maroon;font-size:10px;"/>
                                </dvt:pointLocation>
                            </dvt:pointDataLayer>
                        </dvt:areaLayer>
                    </dvt:thematicMap>

SelectionListener code to get selected location value

import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.RowKeySet;
import java.util.Iterator;

/**Method to get selected marker value in Managed Bean
* @param selectionEvent
*/
public void mapSelectionListener(SelectionEvent selectionEvent) {
//getDataLayerBind is binding of dvt:pointDataLayer on page.
RowKeySet selectedMarker = getDataLayerBind().getSelectedRowKeys();
//Create iterator from RowKeySet
Iterator iter = selectedMarker.iterator();

while (iter.hasNext()) {
String i = iter.next().toString();
//LocationDetail is the list used to populate table and name is a column of table
//So here filter list using index and get values then
LocationDetail mapRow = mapDetail.get(Integer.parseInt(i));
FacesMessage msg = new FacesMessage(“Selected Marker is: “ + mapRow.getLocation());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}

All Done 🙂 Run and check application

dvt:thematicMap in ADF Faces

 

Related Posts

I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF

0 thoughts on “Enable selection and Get selected marker value from dvt:thematicMap in ADF Faces”

  1. Hello
    question If possible
    How can I use adf security provided specific column data
    For example :
    No. 1 user can see all the data in which No. 1
    And No. 2 user can see all the data in which No. 2
    Etc ..

  2. The world map and the selected city within the world map should be marked very well so that the interested people can know.The pro custom writing review will let the people know about the benefits of learning the unknown issues.There are some apps for decorating the apps for arranging the selected cities.

  3. Hi Ashish,

    I have more than one tab in my application. This issue is occurring while filtering a column in any tab. When we provide any text in filter option and hit enter.
    Filtered results are displaying correctly. But when user switches to other tab and returns to previous tab, the entered text in column filter option is appending with * symbol.
    Example: I have two tab Employee and Departments. User is currently in Employee tab and filtered “Name” column by entering “Tiger”.
    All the results related to Tiger are displayed. Then we moved to Department tab and returned to Employee tab, Tiger* is displaying as filter text . This is occurring in all filter columns.

    Please help me on this.

Leave a Reply

Your email address will not be published. Required fields are marked *