3

i ve this code in my application i want to submit h:selectBooleanCheckbox value to server, h:selectBooleanCheckbox inside p:tabView and outside p:dataTable i want to submit h:selectBooleanCheckbox value from p:ajax process="scenarioTabViewId:isApprovedBooleanId_checkBox" scenarioTabViewId:isApprovedBooleanId_checkBox this is checkbox id created by firefox v23.0 and scenarioTabViewId:budgetAnalysisDataTableId this is datatable id can any one explan,how can i do this? this is actual code in .xhtml

<ui:composition template="/template/mastertemplate.xhtml">
  <ui:define name="content">
     <h:form styleClass="form" prependId="false">
       <p:panel id="analysisTheBudgetPenel" header="Analysis The Budget">
           <p:tabView id="scenarioTabViewId" style="width:850px">
              <p:tab title="Scenario One" id="scen">
                  <h:selectBooleanCheckbox id="isApprovedBooleanId_checkBox" value="#{budgetAnalysisAction.budgetScenarioHescoProposalBean.abc}" />
                  <p:scrollPanel style="width:800px; height:auto;">
                  <p:dataTable id="budgetAnalysisDataTableId" rowIndexVar="index" editable="true" resizableColumns="true" value="#{budgetAnalysisAction.budgetScenarioHescoProposalBean.budgetScenarioHescoProposalListBean}" var="budgetScenarioHescoProposalList">
                     <p:ajax event="rowEdit" process="#{scenarioTabViewId:isApprovedBooleanId_checkBox}" listener="#{budgetAnalysisAction.testAjax}" />
// some columns
// closing tags of above

thanks in advance

Mohsin AR
  • 2,998
  • 2
  • 24
  • 36

1 Answers1

2

First of all, remove <h:form prependId="false">. It's incompatible with ajax. Don't forget to give the form a fixed ID now.

<h:form id="formId" styleClass="form">

Secondly, the process attribute is in your case wrong, you were using an EL expression with the component's cliend ID as a variable in the EL scope. This isn't making any sense. Just make it a normal string.

The rules of referencing the proper client ID can be found in the following answer: How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar". Applying that, it should look something like this (note the : prefix):

process=":formId:scenarioTabViewId:isApprovedBooleanId_checkBox"

An alternative would be to bind the physical checkbox component to the view like so:

<p:selectBooleanCheckbox binding="#{checkbox}" ... />

And then reference its client ID with help of UIComponent#getClientId() like so (also here, note the : prefix):

process=":#{checkbox.clientId}"
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • oh sorry i did mistake on writing this process="#{scenarioTabViewId:isApprovedBooleanId_checkBox}" my actual code is process="scenarioTabViewId:isApprovedBooleanId_checkBox", why should i remove this ? can you make me understand ? – Mohsin AR Aug 25 '13 at 19:48
  • JSF won't be able to find right component this way. The `prependId="false"` isn't taken into account in `findComponent()`. The `prependId="false"` is merely client side, i.e. it affects only the generated HTML element ID. See also last paragraph of the linked answer. The `prependId="false"` should only be used in very specific (and non-ajax) use cases. In real world code, there's generally never a valid need for it. Just stop using that. – BalusC Aug 25 '13 at 19:48
  • thanks dear you are awesome!! this statement (process=":formId:scenarioTabViewId:isApprovedBooleanId_checkBox") is useful for me.. can you tell me from where can i do deep study about jsf 2 ? – Mohsin AR Aug 25 '13 at 19:55
  • i have done this(prependId="false") because some where in my application i ve written a general method called getCountriesByIdsOnAjax() (which is invoking by many froms in different xhtml files) which is returning names of countries when i change countryselect value i have invoked getCitiesByIdsOnAjax() it returns names of citites (U.S.A--> NY), – Mohsin AR Aug 25 '13 at 20:35
  • continuing above when i change countryselect i get that value in server by getrequestparameter("country") if i dont write this (prependId="false") then onChange countryselect from many xhtmls (different forms from different xhtml files) i get values on request like this "form1:countrySelect" "form2:CountrySelect" and so on. – Mohsin AR Aug 25 '13 at 20:36
  • Just use JSF for that part: http://stackoverflow.com/questions/11505248/how-to-display-list-of-countries-and-cities-in-jsf-page/11505860#11505860 – BalusC Aug 25 '13 at 21:24
  • i am not understanding this the link you have shared in that you have written there is also a
    then why dont that condition written like this
    – Mohsin AR Aug 25 '13 at 23:35
  • If the referenced client ID does not start with `:`, then it's searched within the parent `NamingContainer` component, which is the ``. – BalusC Aug 26 '13 at 00:22
  • thanks for sharing link about @postConstruct well i am using prettyfaces in my app your post was not my solution but for that post i review my code again and fix prependId="false" in many xhtml files.. i use but i forget to use execute="someId" , for that i didnot get someId on server. and i got someId using Map params = externalContext.getRequestParameterMap(); params.get("someid"); but now i fixed this – Mohsin AR Aug 26 '13 at 08:16