• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf and external urls  RSS feed

john kikuvi
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have this code
<form name="myform" action="http://localhost:8080/EASYPAY.COM/faces/newxhtml.xhtml"method="post">
<input type="text" name="amount"value="">
<input type="submit" >

i want to post value of amount to this jsf page
<f:viewParam name="amount" value="#{viewParamManagedbean.amount}" ></f:viewParam>

this is my managed bean
package softmint.com;

import java.io.Serializable;
import javax.faces.bean.ManagedProperty;

* @author kikuvi
public class ViewParamManagedbean implements Serializable {

String amount;

public String getAmount() {
return amount;

public void setAmount(String amount) {
this.amount = amount;


when i submit the html form the value of amount does not appear in the second jsf page new.xhtml what might be the problem
Tim Holloway
Posts: 18662
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a couple of things wrong with that.

Most importantly, you have confused a URL with a resource.

A webapp resource is the "file" within a WAR that is used as part of the process of resolving a URL request. For example:

is a URL that in the most common JSF configuration scheme will cause the FacesServlet to tear down the URL to determine that it should render the resource located at:

The "/faces/*" URL pattern is also often seen in examples, but I don't recommend it. Partly because it's confusing, partly because I like shorter URLs.

As a general rule, JSF is supposed to maintain its data on the server. Parameterized URLs are therefore to be discouraged, as the server-side environment can generally know what you want without polluting the View with what is essentially a logic construct. Also most JSF navigation isn't done with a URL, it's done as an action from a JSF h:form, which, unlike the raw HTML FORM tag, carries additional JSF support information. The exceptions to that are when you are jumping directly to a JSF view (possibly from a bookmark or manual browser request) or because a non-JSF webpage wishes to link to a JSF View.

Having said all that, I suspect that your #1 problem, however the scope of your backing bean, since I don't see one declared. And, for that manner, you've defined what appears to be an unmanaged bean with a managed property, which probably won't work at all. A JSF View request references Managed Beans, and in almost all cases, those beans need to be at View, Session, or Application scope. Request scope is not very useful in JSF, owing to architectural reasons, and mostly it just gets people into trouble.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!