How do I submit some h:inputText field/send custom data while p:autocomplete sends a query for fetching suggestions from server. I tried doing like this:
<p:autoComplete completeMethod="..." >
<p:ajax event="query" onstart="method1()" process="@this, field1"/>
</p:autoComplete>
<h:inputHidden id="field1" value="#{search.value2}"/>
The field seems to be submitted along with the sent data to the server however the value is not set in managed bean. Probably the process attribute of above p:ajax does not seem to work correctly for above case. So, How do I submit this h:inputHidden#field1 along with query for suggestions ?
Submit a inputfield with p:ajax#query within p:autocomplete
You have 155 posts
http://forum.primefaces.org/viewtopic.php?f=3&t=1194
Points 2,3 and 9
And with just code snippets, most likely noone will take the effort to make it a full working example to try to anlyze it. You should know all this by now. And with a full example I mean bean xhtm but all as minimal as pussible but FULLY working (no compile errors etc)
http://forum.primefaces.org/viewtopic.php?f=3&t=1194
Points 2,3 and 9
And with just code snippets, most likely noone will take the effort to make it a full working example to try to anlyze it. You should know all this by now. And with a full example I mean bean xhtm but all as minimal as pussible but FULLY working (no compile errors etc)
-
- Posts: 69
- Joined: 02 Jun 2013, 18:37
My approach to these types of problems starts with looking at the uncompressed javascript source. I see that PrimeFaces.widget.AutoComplete has a search function which gets its value from _self.input, so you'll need to re-implement the method. I will assume that you are not using composite components, that the id of the autocomplete is "autocomplete", and that you are using a version of PrimeFaces which has the PF() client-side method.
The key points to note here are that we are replacing the original search with a new implementation, although it's the exact same code with one line added at the beginning to facilitate the passing of the 2nd value. The script must go AFTER the component tag. The CDATA block is a precaution and may not be necessary. If the code for search changes in future releases of PF, then you would need to revisit this piece. The component names here are simplified and will need to be adjusted as needed. You may format the query as you desire, but the purpose here is to illustrate one possible solution. Who knows, maybe you want to format it as a JSON string? Hope this helps...
Code: Select all
<p:autocomplete id="autocomplete" ... />
<script type="text/javascript">
//<![CDATA[
$(function() {
PF("autocomplete").search = function(query) {
query += "," + $(PrimeFaces.escapeClientId("field1")).val();
...Copy of original code...
}
})
//]]/>
</script>
PF 5.0
PF Ext 0.7.1
OmniFaces 1.7
Tomcat 7.0.37
JSF 2.1.24
PF Ext 0.7.1
OmniFaces 1.7
Tomcat 7.0.37
JSF 2.1.24
I have a very common problem described here with a full example
http://forum.primefaces.org/viewtopic.php?f=3&t=39065
Do i really have to edit primefaces source code to get this working?
http://forum.primefaces.org/viewtopic.php?f=3&t=39065
Do i really have to edit primefaces source code to get this working?
-
- Information
-
Who is online
Users browsing this forum: Google [Bot] and 32 guests