Hello, I have a question about using <h:commandButton>. In my application, I am trying to use a commandButton to delete a record from the database. I was using a commandLink and using a <f:param> to pass in the id of the record to be deleted. The requirements changed and a pop-up window for deletion confirmation is now requested. From what I understand, commandLink (in JSF 1.1) does not support the use of onclick to call a javascrip confirmation function. However, I cannot figure out how to pass the parameter by using a commandButton. Any advice would be nice.
This is the code snipet I was using before the change:
This is what I had been attempting to do with no avail:
Thank you in advance.
Narendran Nair
Ranch Hand
Joined: Sep 25, 2003
Posts: 35
posted
0
copy the getParameter to the desired type use this code in the backing bean ... thats all .........
I had similar problem, and your advice helped. but it is strange that the parameter is not passed to my backing bean and I have to use the code you've provided.
I have a list of objects with IDs:
ViewTests class has suiteId: private Long suiteId; (with getters and setters),
and performSearch() method always sees NULL suiteId.
why doesn't a Long parameter work? I tried to change it to Sting, but it did not help: it is still not passed to the backing bean. [ August 16, 2006: Message edited by: Alex Skor ]
Daniel Rhoades
Ranch Hand
Joined: Jun 30, 2004
Posts: 186
posted
0
I personally get them from the requestMap:
FacesContext context = FacesContext.getCurrentInstance(); Object value = context.getExternalContext().getRequestMap().get("paramName");
Drinking more tea is the key...
Sudeep Agrawal
Ranch Hand
Joined: May 31, 2006
Posts: 34
posted
0
I am not able to view the parameter <f:param> that I pass in the the <h:commandLink>. The backing bean was tried in both "Session" scope and "Request" Scope. The Map Attribute I got were something like this :
"I am using actionListener and not action method", would this make a difference?
Please advice how can I pass parameters via. commandLink.
Another thing you can do in the JSF action for the commandButton is grab the target bean you are going to from the faces context and set the parm value directly. Here is sample code the the action, userInfobean is the backing bean for the target JSP:
Bill Lyons
Greenhorn
Joined: Jan 24, 2002
Posts: 7
posted
0
Originally posted by Daniel Rhoades: I personally get them from the requestMap:
FacesContext context = FacesContext.getCurrentInstance(); Object value = context.getExternalContext().getRequestMap().get("paramName");
Hi folks,
This post is almost correct. The 2nd to last get needs to be on getRequestParameterMap() instead of .getRequestMap
The corrected code should read: FacesContext context = FacesContext.getCurrentInstance(); Object value = context.getExternalContext().getRequestParameterMap().get("paramName");
I am passing a paramter from a commandLink in the same way that was discussed. In my backing bean I am also getting the value in this way:
Its working great in FireFox >2.0.2 but when I try and use the site in IE6 the parameter is not being passed through. (String)requestMap.get("paramName") is returning null.
Is there something specific I need to do for parameters to work for commandLinks in IE?
Thanks, S
Seamus Minogue
Ranch Hand
Joined: Jun 24, 2008
Posts: 41
posted
0
Never mind. I found my answer.
Wasnt even a JSF issue.
It seemed that for some reason FF had no problem with <input name="id"/> and IE simply dropped it.
I changed the name to be somethingId and it works fine.
Oh I love these little differences between browsers...
Chris Lewis
Greenhorn
Joined: Jul 17, 2008
Posts: 1
posted
0
Originally posted by Seamus Minogue:
It seemed that for some reason FF had no problem with <input name="id"/> and IE simply dropped it.
Thanks for sharing your solution - that was exactly my problem. [ July 17, 2008: Message edited by: Chris Lewis ]