Faces in ADF can't get the request parameters

寵の児 提交于 2019-12-13 03:34:29

问题


I have an ADF web application with Faces 1.2

In my managed bean I am trying to access the parameters of the post request, but always getting null.

This is my post form that I am posting to the Faces:

<form name="input" action="http://127.0.01:7072/myapplication/faces/login.jspx" method="post">
   <input type="hidden" name="user" id="user" value="myUserName"/>
   <input type="submit" value="Submit"/>
</form>

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("user");

FacesContext.getCurrentInstance().getExternalContext().getRequest().getParameter("user");

But I always get null and the method of the form I get is: GET, strange!


回答1:


when you make a request for a URL like:

http://server/faces/somepage.jspx

ADF framework respone you by a "HTTP Error 302 Moved temporarily" response and redirect you to the URL like :

http://server/faces/somepage.jspx?_adf.ctrl-state=888888&_afrLoop=9999999

so your first POST request is omit and browser send an other request to the new URL that ADF returned in response, so because POST method send parameter in the request body the browser dont resend them in new Get request so i think there is no way for you to get parameters direcly in side the ADF page ! :(

but i think the best way is to create a Servlet and get you param in it and put them to session and then redirect the user from servlet to your ADF page :)




回答2:


I managed reading the request parameters through including my parsing operations in the filter mappings that my application was using.

In a very abnormal way FacesContext always rejected revealing the current parameters, till now it's a mystery for me why it's designed liked that, even through its external context ...



来源:https://stackoverflow.com/questions/23503948/faces-in-adf-cant-get-the-request-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!