i have a huge jsf-page with an underlying ViewScopeBean that contains a very large form (containing nearly 100 inputs) with many ajaxified input fields. for every input field, i only submit the current value and render nothing. so just a sample field in that form:
<h:selectBooleanCheckbox id="includeForeignCurrencies"
value="#{RatingManagerBean.formData.foreignCurrencies}"
action="#{RatingManagerBean.calculate}">
<f:ajax render="@none" execute="includeForeignCurrencies"/>
</h:selectBooleanCheckbox>
after the ajax post i inspect e.g. the developer tools in firebug and recognize that the submitted size of the post data is up to 2 kb. then i select the row, choose "copy post data" and pasted it into an editor:
every field of that form is submitted although i am only interested in the current changed field:
form-search=form-search
countryCode=AT
ratingType={"type":"COUNTRY"}
averageRating
minAmount
maxAmount
averageAmount
company
location
staffResponsible
staffResponsible2
requestDate
reminderDate
acutalCurrency
compareCurrencies
//70 other empty form-ids....
includeForeignCurrencies=on
javax.faces.ViewState=1825148886808299106:-354534052529224349
javax.faces.source=includeForeignCurrencies
javax.faces.partial.event=click
javax.faces.partial.execute=includeForeignCurrencies
javax.faces.behavior.event=valueChange
javax.faces.partial.ajax=true
is there a way to reduce the posted data like:
includeForeignCurrencies=on
javax.faces.ViewState=1825148886808299106:-354534052529224349
javax.faces.source=includeForeignCurrencies
javax.faces.partial.event=click
javax.faces.partial.execute=includeForeignCurrencies
javax.faces.behavior.event=valueChange
javax.faces.partial.ajax=true
or even just
includeForeignCurrencies=on
thanks in advance!
Workaround:
as a possible workaround i came up with disabling all inputs that did not trigger the post and re-enable them in ajax complete. post data size is now 200 B instead of 2000 B.
as i am not sure if this may cause any other issues, this is an update of the question, not an answer.
<h:selectBooleanCheckbox id="includeForeignCurrencies"
value="#{RatingManagerBean.formData.foreignCurrencies}"
action="#{RatingManagerBean.calculate}"
onclick="prepareAjaxPost(this)">
<f:ajax render="@none" execute="includeForeignCurrencies" onevent="ajaxPostComplete"/>
</h:selectBooleanCheckbox>
javascript/jQuery:
function prepareAjaxPost(source){
//keep already disabled inputs disabled
$("#form-search :input:not(:disabled)").filter(function() {
return !this.id.match(/javax.faces.ViewState/); //all inputs ignoring jsf- viewstate ones
}).each(function(){
var input = $(this);
var others = input.not(source);
others.attr("disabled", true);
others.addClass("blocked"); //some style that has no visual effect for users
});
}
function ajaxPostComplete(data) {
switch (data.status) {
case "success": {
$("#form-search :input.blocked").each(function(){
$(this).attr("disabled",false).removeClass("blocked");
});
break;
}
}