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 Not able to use action attribute in JSF graphicImage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Not able to use action attribute in JSF graphicImage" Watch "Not able to use action attribute in JSF graphicImage" New topic
Author

Not able to use action attribute in JSF graphicImage

Vikas Taank
Greenhorn

Joined: Oct 08, 2008
Posts: 6
Hi,
I am using the following code to display graphic image.
<h:graphicImage id="fiPricePendingToolRefreshImage"
value="/images/refresh.jpg">
<rich:toolTip for="fiPricePendingToolRefreshImage"
followMouse="true" direction="top-right" showDelay="200"
styleClass="tooltip">
<span style="white-space: nowrap">Refresh</span>
</rich:toolTip>
</h:graphicImage>

Graphic Image does not have attribute like "action". So I am enclosing this image in the <a4j:commandLink> like this:
<a4j:commandLink id="Refresh"
action="#{fiPriceController.downloadFile}">
<h:graphicImage id="fiPricePendingToolRefreshImage"value="/image/refresh.jpg"><rich:toolTip for="fiPricePendingToolRefreshImage"
followMouse="true" direction="top-right" showDelay="200"
styleClass="tooltip">
<span style="white-space: nowrap">Refresh</span>
</rich:toolTip>
</h:graphicImage>
</a4j:commandLink>

But in the above case my action method is not getting invoked.
If I use command button to invoke the same action method. It's working fine and I am able to download the file.
<h:commandButton id="export"
action="#{fiPriceController.downloadFile}">
</h:commandButton>

has anybody ever used the <h:graphicImage> to invoke the action method and how it has been done. Please reply as it is very critical to my project.
Thanks in advance.
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Well I am not sure about a4jCommandLink but i tried the same case with <h:commandLink> and found that it is working.

For your understanding I am providing the code too. Hope this will help you.

--------------------------------------------------------------------
The page Code
--------------------------------------------------------------------
<h:form>
<a4jutputPanel id="banner" styleClass="banner" layout="block">
<a4jutputPanel id="banlogo" styleClass="banlogo" layout="block">
<h:commandLink action="#{loginBean.login}" >
<h:graphicImage value="images/ui/logo1.gif"
width="180" height="60" style="border:none;">
</h:graphicImage>
</h:commandLink>
</a4jutputPanel>

</a4jutputPanel>
</h:form>

--------------------------------------------------------------------
The Bean Code
--------------------------------------------------------------------

public String login() throws Exception {
System.err.println("in Login<------------------");

return "success";
}

--------------------------------------------------------------------
The Console Output
--------------------------------------------------------------------

[10/8/08 15:29:11:236 BST] 00000028 SystemErr R in Login<------------------





Himanshu
[ October 08, 2008: Message edited by: Himanshu Gupta ]

My Blog SCJP 5 SCWCD 5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Not able to use action attribute in JSF graphicImage