Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JSF Error

  Asked By: Egidius    Date: Jul 28    Category: Java    Views: 1707
  

I am getting this error :


javax.faces.el.EvaluationException: java.lang.UnsupportedOperationException

for this code :

FacesContext. getCurrentInstance().getExternalContext().getRequestParameterMap().put( "myKey", "myVlaue");


Does anybody know how to fix it?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Eddie Austin     Answered On: Jul 28

if you are using jsf  so why not make most use of it? Why do you try to use old features of web!!!

instead of using request parameters, you had better to put  a field in your managed bean.
this RequestParameterMap is readonly structure.

consider you have a jsf managed bean as follow:


class MyBean {

private String myKey;

//somewhere in your code: myKey = "myValue"

public String getMyKey(){
return myKey;
}
}


now in you pages:

#{myBean.myKey} can be accessed!

 
Answer #2    Answered By: Antonio Dunn     Answered On: Jul 28

This is a simple example of use these article :


public FileUploadForm() {
if(FacesContext.getCurrentInstance().getExternalContext().
getRequestParameterMap().containsKey("defaultsavepath_name"))
{
this.savePathName=FacesContext.getCurrentInstance().
getExternalContext().getRequestParameterMap().
get("defaultsavepath_name").toString();

FacesContext.getCurrentInstance().getExternalContext().
getRequestParameterMap().put("defaultsavepath_name",this.savePathName);
}
else
{
Object tmpDir =
FacesContext.getCurrentInstance().
getExternalContext().getRequestParameterMap().get("dirName");
if (tmpDir != null && !tmpDir.toString().equals(""))
{
String tmpdirName = tmpDir.toString();
savePathName = savePathName + "\\" + tmpdirName;
FacesContext.getCurrentInstance().getExternalContext().
getRequestParameterMap().
put("defaultsavepath_name", this.savePathName);
}
...
}

 
Answer #3    Answered By: Holly Brown     Answered On: Jul 28

If you have an Exception use this line instead of it :
FacesContext.getCurrentInstance().getExternalContext().getRequest().getSession().setAttribute("myKey") = myValue;

 
Answer #4    Answered By: Maliha Malik     Answered On: Jul 28

You are going wrong way. ;) JSF doesn't support everything not to let
programmers do invention in their codes ;) Maybe Struts or pure JSP
would be a better choice for them.

 
Answer #5    Answered By: Edward Jones     Answered On: Jul 28

please take a look at managed properties

they are the proper way to transfer one object from one managed bean to other in JSF
also if you are using seam with JSF, you can use the seamn injection, outjection and bijection mechanisms.
this makes your code  much more readable and maintainable.

 
Didn't find what you were looking for? Find more on JSF Error Or get search suggestion and latest updates.




Tagged: