Hi,
 
I used <h:graphicImage> tag with usemap attribute in IBM's implementation of JSF and its working fine.
a code snippet :
 
<h:graphicImage style="border=0" id="graphicImageId"
url="/images/#{pc_TestView.imageName}"
usemap="#{pc_TestView.mapName}">
</h:graphicImage>
 
A sample map tag :
 
<MAP name="AU">
<AREA shape="rect" alt=""
onclick="return selectedArea('AU-MEL', this.form)"
coords="99,170,165,182" href="#">
<AREA shape="rect" alt=""
onclick="return selectedArea('AU-GLDV', this.form)"
coords="193,141,263,154" href="#">
</MAP>
 
I call a _javascript_ 'selectedArea' and pass the value that I want in managed bean. I assign this value to a hidden jsf component
in the _javascript_.
This way I am able to find out the clicked area and proceed further with my logic.
 
Hope this is useful in Myfaces also..:)
 
Regards,
Sunil
 
 
----- Original Message -----
From: "Sean Schofield" <[EMAIL PROTECTED]>
To: "MyFaces Discussion" <users@myfaces.apache.org>
Sent: Friday, August 19, 2005 9:34 AM
Subject: Re: How to find out the co-ordinates when I click on a world map(Image)?

> Yes a world map will be tricky but this is still a cool solution :-)
>
> sean
>
> On 8/18/05, Sunil Tiwari <
[EMAIL PROTECTED]> wrote:
>> Hi Sean,
>>
>> Thanx for this useful information.
>> I searched a lot yesterday on this topic and I got the same information that
>> you have provided.
>> We can use image in the commandButton and can get the pixel coordinates when
>> clicked anywhere on the image.
>> And then this coordinate can be used to divide the image into various
>> regions.
>>
>> The problem will be mapping if the image is complex like a world map and you
>> want to click on any country.
>>
>> I am also looking into html IMG tag and usemap.
>> I can call a _javascript_ on the <Area> tag and pass on a parameter and this
>> parameter can furthur be passed on to the managed bean.
>> I will try implementing this way and tell the result later on.
>>
>> Thanx again for following it up!
>>
>> Regards,
>> Sunil
>>
>> ----- Original Message -----
>> From: "Sean Schofield" <
[EMAIL PROTECTED]>
>> To: "MyFaces Discussion" <
users@myfaces.apache.org>
>> Sent: Friday, August 19, 2005 3:54 AM
>> Subject: Re: How to find out the co-ordinates when I click on a world
>> map(Image)?
>>
>>
>> >I am in the process of re-reading the excellent Core JSF book by Geary
>> > and Horstmann.  (I had initially only skimmed it having already read 3
>> > other JSF books.)  There are some interesting nuggets in there
>> > including the following:
>> >
>> > According to them, you can do this with <h:commandButton> and a
>> > combination of action and actionListener.
>> >
>> > <h:commandButton image="foo.jpg" actionListener="#{backer.listen}"
>> > action=""/>
>> >
>> > I was suprised that you can apparently get the mouse click coordinates
>> > from the listener ... you can then set a variable in the backer so
>> > that your action method can use it in navigation (if that's what you
>> > need.)
>> >
>> > public void listen(ActionEvent e)
>> > {
>> >   ...
>> >
>> >   Map requestParams =
>> > context.getExternalContext().getRequestParameterMap();
>> >   int x = new Integer((String)requestParams.get(clientId +
>> > ".x")).intValue();
>> >
>> >   ...
>> > }
>> >
>> > There is more great stuff like this in Core JSF so check it out!
>> >
>> > sean
>> >
>> >
>> > On 8/18/05, Sunil Tiwari <
[EMAIL PROTECTED]> wrote:
>> >> Hi,
>> >>
>> >> Cld you give me this component so that I can try implementing the same on
>> >> websphere?
>> >>
>> >> Thanx
>> >> Sunil
>> >>
>> >> ----- Original Message -----
>> >> From: "Mario Ivankovits" <
[EMAIL PROTECTED]>
>> >> To: "MyFaces Discussion" <
users@myfaces.apache.org>
>> >> Sent: Wednesday, August 17, 2005 7:24 PM
>> >> Subject: Re: How to find out the co-ordinates when I click on a world
>> >> map(Image)?
>> >>
>> >>
>> >> > Martin Marinschek wrote:
>> >> >>Ideally,
>> >> >>
>> >> >>you would build an image map JSF component.
>> >> >>
>> >> > I already created such a component,, but maybe its too limited to get
>> >> > added to myfaces.
>> >> > Its sort of "my first component" and maybe too restricted to my
>> >> > application.
>> >> > I used it in conjunction with jfreechart to be able to click into the
>> >> > graph.
>> >> >
>> >> > It works like this:
>> >> >
>> >> > <h:inputHidden id="annotateEvent"
>> >> > value="#{AnnotationForm.eventNumber}"/>
>> >> > <h:graphicImage
>> >> >        binding="#{EventDataProvider.image}"
>> >> >        url=""
>> >> >        alt="WateringData"
>> >> >        width="900"
>> >> >        height="600"
>> >> >        usemap=""
>> >> >        />
>> >> > <s:area
>> >> >        mapName = "CHART_TOOLTIP"
>> >> >        action = ""
>> >> >        areas="#{EventDataProvider.areas}"
>> >> >        destField="annotateEvent"
>> >> >        />
>> >> >
>> >> > The hidden field is required for the s:area component (see destField=).
>> >> > With my knowledge today I could get rid of this hidden field.
>> >> > The areas are passed in through an ArrayList of ImageMapArea.java
>> >> > instances which is a simple bean with "shape, coords, title and data".
>> >> > data is the value you might find in "destField" then.
>> >> >
>> >> > Sayed all that: If one find it useable that way I can contribute it.
>> >> >
>> >> >
>> >> > ---
>> >> > Mario
>> >>
>> >>
>>
>>

Reply via email to