I have rich:popupPanel which contains t:dataList under one column of t:dataTable. This dataList has h:commandLink which has f:param inside it. It was working fine for richfaces 3.3 but after migration to richfaces 4, it stopped working. To mention the fact that I was using rich:modalPanel in place of rich:popupPanel over there. I went through quite a few links:
https://community.jboss.org/thread/202583
commandButton/commandLink/ajax action/listener method not invoked or input value not updated
but of no help :(. Am I missing something? Currently, bean is session-scoped and I am using getter to fetch the data model as its not possible for me to put it in constructor.
Please let me know, if someone has idea about it.
PS: Rendered HTML equivalent looks like this. It has request parameter varPath but in backing bean we get it as null.
<a onclick="return myfaces.oam.submitForm('actionForm','actionForm:j_id0',null, [['varPath','/Link']]);" href="#" tabindex="-1" accesskey="">/Link</a>
Figured out that changing the encType of form to "application/x-www-form-urlencoded" from "multipart/form-data" resolves this issue. Strange though! Not sure why it didn't work with multipart encryption.
First of all, it's not an encryption, but an encoding. The difference is pretty huge. "Encrypting" is a way of changing the value in such way which is not predictable without having kind of a security key (cipher key, seed, etc). "Encoding" is a way of changing the value in such way that it's acceptable by the data transfer mechanism and/or that it's recognizeable/parseable by the other side without loss of any data. The values are not made unreadable or something, they are just arranged somewhat specific and differently.
Coming back to your concrete problem, the multipart/formdata
encoding is usually only used when you need to be able to send (upload) a file along with the form, using for example <input type="file">
or the RichFaces <rich:fileUpload>
component. The standard application/x-www-form-urlencoded
form encoding, which basically specifies that the request parameters should be sent URL-encoded in this format
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
name1=value1&name2=value2&name3=value3
isn't suitable for passing file contents around. For that the multipart/form-data
encoding should be used which basically look like this:
Content-Type: multipart/form-data;boundary=SOME_BOUNDARY
--SOME_BOUNDARY
content-disposition: form-data;name="name1"
content-type: text/plain;charset=UTF-8
value1
--SOME_BOUNDARY
content-disposition: form-data;name="name2"
content-type: text/plain;charset=UTF-8
value2
--SOME_BOUNDARY
content-disposition: form-data;name="name3"
content-type: text/plain;charset=UTF-8
value3
--SOME_BOUNDARY--
This format allows room for enclosing complete file contents in the request body.
In a JSF 2.0/2.1 web application, multipart/form-data
requests are normally processed by a custom Filter
. In case of RichFaces 3, this is normally processed by the org.ajax4jsf.Filter
which is missing in RichFaces 4.
Note that the application/x-www-form-urlencoded
is already the default encoding type of HTML forms. So you don't need to explicitly specify it yourself. Just omit the enctype
attribute altogether:
<h:form>
</h:form>
and you should be all set.
Figured out that changing the encType of form to "application/x-www-form-urlencoded" from "multipart/form-data" resolves this issue. Strange though! Not sure why it didn't work with multipart encryption.
Would still like to know the explanation behind this, if anyone knows about this.
Using a4j:commandLink instead of h:commandLink pass parameters correctly which resolved this issue. No need for custom filters just for parameters.
CommandButton should be placed in a form tag. Sounds like you have nested form or you have no form.
来源:https://stackoverflow.com/questions/12156068/params-not-getting-passed-to-backing-bean-for-hcommandlink-under-richpopuppane