This discussion is archived
6 Replies Latest reply: Jan 29, 2013 2:15 AM by 968650 RSS

Get parameter from URL in Java code

968650 Newbie
Currently Being Moderated
Hello everyone,

I've got strange problem. I have one JSF page with two controls:
- InputText
- Button

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="view12.jsf" id="d1">
<af:messages id="m1"/>
<af:form id="f1">

<af:inputText label="Label 1" id="it98" value="#{param.test}" editable="always"/>
<af:commandButton actionListener="#{bindings.przekierowanie.execute}" text="przekierowanie"
disabled="#{!bindings.przekierowanie.enabled}" id="cb1"/>
</af:form>
</af:document>
</f:view>


And I want to initialize the InputText with parameter from URL (param name is test - value="#{param.test}"). In JSF page everything is fine. But after clicking button I have to read the value from InputText in Java Code, so I have URL:

http://127.0.0.1:7101/Application6-ViewController-context-root/faces/view12.jsf?test=asd

and my Java code which is executed after clicking button is:

public String przekierowanie() {
Map <String,String> map=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String tttValue=map.get("test");
System.err.println("test:" + tttValue);
     return null;
}

but this doesn't work... Everytime I get null when I click the button. Could you tell me why and How to obtain this value, from InputTex in my java function?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points