File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Changing target of commandLink in actionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Changing target of commandLink in actionListener" Watch "Changing target of commandLink in actionListener" New topic
Author

Changing target of commandLink in actionListener

Jeff Lindquist
Greenhorn

Joined: Apr 29, 2011
Posts: 3
Hello,

I have an application that uses frames. I am trying to set up a commandLink using a target frame, but the necessity is that I need to determine which frame to use based on the method in the actionListener. Is this possible?

Basically what I want to do is this:



Where target isn't determined until after the actionListener, but of course this won't work as the target is determined much earlier.

Thanks for any help,

Jeff
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

ActionListeners are overused. Their primary utility comes when you want to attach multiple actions to one command.

However, whether you employ an ActionListener or just a plain vanilla action, the value of the target AFTER all the action processing is completed should be what defines things unless I'm mistaken. So, in other words, just set the bean property in the actionListener and you should be OK.

It's one of the reasons that you code an EL value reference, rather than a static one-time expansion on original page display.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeff Lindquist
Greenhorn

Joined: Apr 29, 2011
Posts: 3
Hi Tim, thanks for replying.

I made the function "getTarget" output something and when I load the initial page it outputs the string, so the target is being set on page load and not once the action is finished processing unfortunately. That's the problem is I need to use the input from the page to determine the target, but from my testing and what I can tell the target needs to be determined on page load. That's the workaround I was hoping for.

Jeff
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Darn. I was afraid of that. Welcome to the Ranch, BTW!

I think you'll probably need to do an AJAX thing then. Modify the generated element right before it gets sent to the action listener rather than in the action listener, because when the action listener gets done, the client is then going to zap the current page and begin outputting the new one, losing any changes done from that point on before they can be seen and acted on.
Jeff Lindquist
Greenhorn

Joined: Apr 29, 2011
Posts: 3
Darn, I was afraid of that.

Thanks Tim!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing target of commandLink in actionListener
 
Similar Threads
compiler error
windows.open()
How do I set actionListeners in code
Navigation Problem
JSF post form data