Showing results for 
Search instead for 
Did you mean: 

java question

0 Kudos

Hello all,

I'm still a novice java developer working on creating a new application for our SAP portal, and I'm stuck on one little thing. Perhaps someone can help me out.

In a jsp page, I have an arraylist of objects. I use an iterator to go through each object in the arraylist. As I go through the arraylist, I use one attribute from each object to create an hbj link to display on the screen. The idea is that the user will be able to click on this link and see the rest of the attributes for that object. What I haven't figured out is how do I indicate which object's link has been clicked. In other words, once the link has been clicked, I don't know how to go through the arraylist to find the object whose fields I need to display.

I've tried setting up the onClick field in the hbj link area to pass a value to the method on the dyn page, but that errored out.

Here's relevant code from the jsp:

ArrayList supplierContacts = sup.getContacts();

Iterator i = supplierContacts.iterator();

String prevContactType = "";

while(i.hasNext()) {

Contact con = (Contact);

String contactName;

contactName = con.getContactLastName() + ", " + con.getContactFirstName();

String linkId = "contactLink" + con.getContactId();



<TD width=550 align=left>

<FONT face=arial size=2>















Here's the relevant code from the Dyn page:

public void onContactLinkClick(Event event) throws PageException {

nextJSP = "ContactDetails.jsp";

} // end method onContactLinkClick

Thanks in advance, I will award points for helpful answers.

-Stephen Spalding

Web Developer


Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

Hi Stephen,

> tried setting up the onClick field in the hbj link


> but that errored out

What was the error? You did it the way you showed here? That should work, if I don't overlook something. The code works (JSP gets compiled) without "onClick=contactLinkClick", but not with it?! If this is the case, on what version are you? Did you try to call the setOnClick method of the link object instead of using the HTMLB notation?!

Ans after the link has been clicked in your onContactLinkClick method, you can cast the event into a LinkClickEvent, see for details. I expect getRef to get the reference which also can be set on the Link object; but you can also check the params if they return for example the id.

Hope it helps


Answers (2)

Answers (2)

0 Kudos

Yes, that did work. I casted my event into a LinkClickEvent and then was able to pull out the id of the link that was clicked. I tried the getRef, getAction, and getComponentName methods. The getComponentName method gave me the name of the link that was clicked. The getRef method returns null, and the getAction method returns what's listed between the double quotes after onClick in the jsp page:


So, in other words, getAction returns "contactLinkClick".

Here's what my onContactLinkClick method now looks like in the dyn page:

public void onContactLinkClick(Event event) throws PageException {

LinkClickEvent l = (LinkClickEvent)event;

String ref = l.getRef();

String action = l.getAction();

String compName = l.getComponentName();

System.out.println("ref = " + ref);

System.out.println("action = " + action );

System.out.println("compName = " + compName);

nextJSP = "ContactDetails.jsp";

} // end method onContactLinkClick

Now I'll be able to grab the id of the link that was clicked and therefore the id in the arraylist of objects. Thanks for your help!

-Stephen Spalding

Former Member
0 Kudos


If u r following JSPDynpages go throughthe following code:

After the action occured in Controller we write the Following code:

public One getSelectedOne() throws Throwable {

final IPortalComponentProfile profile = getProfile();

final TableView tv = ((TableView) this.getComponentByName("myTableView"));

int selected = -1;

for (int i=1; i<=tv.getRowCount(); i++) {

if(tv.isRowSelected(i)){ selected = i;}


if((selected == -1)){ throw new Exception ("Please select .");}

final String id = tv.getRowKey(selected);

final OneDataBean myBean = ((OneDataBean) profile.getValue("myBeanName"));


return acr;


try posting the error also.