A Strange Problem with outputLink...

hi.

i have a very strange problem in using outputLink

whatever i give the link, it redirects the page to the same page only.

my code is as folows:

<h:outputLink value="#{myAction.doSomething">

<f:verbatim>

<h:graphicImage id="submit"

url= "submit.gif"

>

</h:graphicImage>

i have specified the "myAction" in the managed Bean section of faces-config.

can any one tell me what is the problem?

[487 byte] By [Ansh.a] at [2007-11-27 5:15:45]
# 1

now i tried to replace the outputLink with a commandLink as follows

<h:commandLink value="click" action="#{myAction.doSomeThing}"></h:commandLink>

but could not find any diferences

:(

shoud i use actionListener instead of action?

can anybody help me out?

Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

again....

i've switched to outputLink

now my code looks like this

<h:outputLink target="#{myAction.doSomething">

<f:verbatim>

<h:graphicImage id="submit"

url= "submit.gif"

>

</h:graphicImage>

</outputLink>

but still the same output!!!!!!!!!!!!!!!!!!!!!!!

i dont know whats wrong with this?

Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Output links don't invoke actions, so you need to use a CommandLink.

As to why it's going to the same page...

The action="..." on a command link refers to either a

method on a bean that returns a String value and

accepts no arguments, or it can just be a string

literal value.

This value maps to the from-action element within the

navigation-rules you define in your faces-config.xml.

So:

1. What does myAction.doSomeThing return?

2. Do you have a navigation rule configured?

rlubkea at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
This is actually a doublepost: http://forum.java.sun.com/thread.jspa?threadID=5175743
BalusCa at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

hi frnz sorry for posting it twice..

plz ignore my previous thread http://forum.java.sun.com/thread.jspa?threadID=5175743

as you guys suggested i turned my outputLink to the command link again.

here is my codes

myPage.jsp

==========

<h:commandLink value="Click" action="#{myAction.doSomething}" />

myAction

=========

public class MyAction{

public String doSomething()

{

String output = "myString"

return output;

}

}

faces-Config

==============

<managed-bean>

<managed-bean-name>myAction</managed-bean-name>

<managed-bean-class>

com.MyAction

</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<navigation-rule>

<from-view-id>/myPage.jsp</from-view-id>

<navigation-case>

<from-outcome>myString</from-outcome>

<to-view-id>/success.jsp</to-view-id>

</navigation-case>

</navigation-rule>

now can anybody help me?

Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
The code looks fine. Doesn't it work? Is the UICommand element actually been put in an UIForm element? <h:form><h:commandLink ... /></h:form>
BalusCa at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
now i replaced it with a command buttonnow my jsp looks like this<h:commandButton action="#{myAction.doSomething}" image="/images/btn_update_info.gif" />the other files are as it was previous.i'm totally confused what shoul i do and where is the
Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
*What* is the problem?
BalusCa at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
hi Balu.its inside the fotm only!!!!:(
Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
well is there any issue as my button is inside a <td> of a table anf the table is inside the form?
Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
This answer doesn't suit my last question.Anyway, how does the url-pattern of the FacesServlet mapping look like? You might need to adapt the to-view-id on this.
BalusCa at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12

here is my faces servlet mapping

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>*.faces</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>/faces/*</url-pattern>

</servlet-mapping>

but now i noticed 1 thing that the controll does not go to the MyAction class also..

is not it strange?

Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13
Don't you have more elements in the form which can cause conversion or validation errors? Add <h:messages /> to the form and see if an errormessage will show up.
BalusCa at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 14
yepi got an error with h:message that "Error during model data update"what does it mean?
Ansh.a at 2007-7-12 10:38:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 15
Can any one tell me the reason why the controll is not going to the MyAction.java?
Ansh.a at 2007-7-21 21:22:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 16
Hard to say. Likely your form has more elements.Strip out your h:form until you have only the UICommand element. Does it work? If yes, then add element by element back until this error shows up again. Then verify if the last added element is declared and coded correctly.
BalusCa at 2007-7-21 21:22:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 17

well i removed everything from my page

now my page looks like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<f:view>

<body>

<h:form>

<t:inputText value="#{myAction.name}" id="abc" />

<h:commandButton action="#{myAction.doSomething}" image="/images/btn_update_info.gif" />

<h:message for="abc" />

</h:form>

</body>

</f:view>

</html>

still it doesnot work..

now i'm banging my head against the wall

:(

Ansh.a at 2007-7-21 21:22:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 18

now i made a slight change in the code

<h:form rendered=false>

<t:inputText value="#{myAction.name}" id="abc" />

<t:commandButton action="#{myAction.doSomething}" image="/images/btn_update_info.gif" />

<h:message for="abc" />

</h:form>

but the same issue

Ansh.a at 2007-7-21 21:22:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 19

Ah well, you're mixing Sun JSF RI with MyFaces Tomahawk. First try to remove that Tomahawk taglib and replace t:inputText by h:inputText. Or remove the Sun JSF RI and replace all h: by t:.

Which JAR's do you have in your WEB-INF/lib currently?

Can you also show the signature of the getter and setter behind #{myAction.name} ?

BalusCa at 2007-7-21 21:22:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...