Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Managed Bean Method From JavaScript [duplicate]

Tags:

jsf

oracle-adf

I have an application with a client-side image map with multiple sections defined. I need to call a method in the Managed Bean from the <area> onclick attribute.

This doesn't work:

<area id="ReviewPerson" shape="rect" coords="3, 21, 164, 37" href="#" 
    onclick="#{personBean.method}" alt="Review Person" id="reviewPersonArea"
    title="Review Person" />

Since my hands are tied on the image map (unfortunately), how can I call a managed bean method from within the <area> tag?

like image 286
Jason Avatar asked Mar 08 '12 15:03

Jason


1 Answers

If you use primefaces, you don't need jquery. You use remoteCommand with a name attribute, and call that name from javascript, so:

<area... onclick="somejavascript();"... />

<p:remoteCommand name="myCommand" actionListener="#{personBean.method}" style="display: none;" />

Javascript:

function somejavascript(){
   myCommand();
}
like image 122
Matthew Oakley Avatar answered Sep 19 '22 17:09

Matthew Oakley