First time post on stack overflow so apologies if I don't hit the standard expected when asking a question.
We have a JSF page which contains a html table (code below). The table contains 5 columns which needs a response from a user (e.g. picklist, number input etc). The idea is the user selects from a picklist for column id 'condition', and then picks an option for column id 'restored'. If restored is set to yes then we want ajax to be called and enable the final 3 columns 'restored date', 'professionally' and 'restorationCost'.
However what we are finding is that when the user selects their option from 'condition' and then selects yes in 'restored', the final 3 columns will correctly become enabled but the value that was entered in 'condition' is removed and put back to null.
Adding logs to the bean (which has generic getter/setter methods) I can see the value is initially being set but then it's being set again as null following the ajax call. In addition this value is only set to null on the first occasion, if the same steps are repeated either on the same row of the table or on a new row in the table the value persists correctly as we would expect.
A hack solution that works is to add an if query to the set method in the bean to only set the value if the string passed to the method is not null, however this isn't a solution we want to utilise unless it's a last resort.
Can anyone give any help or offer any reasons as to why it is behaving this way? Thanks.
Using Primefaces version 8.0 and the bean is session scoped.
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui" xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<p:outputPanel id="conditions">
<p>CONDITION AND RESTORATIONS</p>
<p>Condition value key:</p>
<ui:repeat var="con" value="#{sessionDataWrapper.sessionData.classicCarDto.conditions}" varStatus="status">
<br/><h:outputText styleClass="mandatoryText" value="#{con.value} - #{con.name}: #{con.description}"/>
</ui:repeat>
<br/>
<table id="conditionsTable" class="conditionsTable">
<tr>
<th></th>
<th id="conditionHeader" class="tableHeader">CONDITION</th>
<th id="restoredHeader" class="tableHeader">RESTORED</th>
<th id="dateHeader" class="tableHeader">DATE</th>
<th id="professionallyHeader" class="tableHeader">PROFESSIONALLY</th>
<th id="costHeader" class="tableHeader">COST</th>
</tr>
<tbody>
<ui:repeat id="conditionsTableSub" var="c" value="#{dto.components}" varStatus="status">
<tr>
<td class="tableFieldName">#{c.name}</td>
<td>
<p:selectOneMenu class="tableDropdown" id="condition" value="#{c.condition}">
<f:selectItem itemLabel="Select" itemValue=""/>
<f:selectItems value="#{dto.conditions}" var="condition" itemLabel="#{condition.value}" itemValue="#{condition.value}" />
<p:ajax event="change" process="@this" />
</p:selectOneMenu>
</td>
<td>
<p:selectOneMenu class="tableDropdown" id="restored" value="#{c.restored}">
<f:selectItem itemLabel="Select" itemValue=""/>
<f:selectItem itemLabel="Yes" itemValue="true"/>
<f:selectItem itemLabel="No" itemValue="false"/>
<f:ajax event="change" process="@this" render=":uploadClassicCarForm:conditions"/>
</p:selectOneMenu>
</td>
<td>
<p:datePicker styleClass="smallDate" inputStyleClass="smallDateInput" panelStyleClass="smallDatePanel" readonlyInput="true" id="restoredDate" view="month" value="#{c.restorationDate}" pattern="MMM yyyy"
hideOnDateTimeSelect="true" yearNavigator="true" yearRange="#{sessionDataWrapper.sessionData.classicCarDto.getYears()}" placeholder="Month, Year" disabled="#{c.restored eq 'false' or c.restored eq null}">
<p:ajax event="dateSelect" process="@this" />
</p:datePicker>
</td>
<td>
<p:selectOneMenu class="tableDropdown" id="professionally" value="#{c.professionallyRestored}" disabled="#{c.restored eq 'false' or c.restored eq null}">
<f:selectItem itemLabel="Select" itemValue=""/>
<f:selectItem itemLabel="Yes" itemValue="true"/>
<f:selectItem itemLabel="No" itemValue="false"/>
<p:ajax event="change" process="@this" />
</p:selectOneMenu>
</td>
<td>
<p:inputNumber class="tableNumber" id="restorationCost" minValue="0" maxValue="999999999" value="#{c.restorationCost}" symbol="£ " emptyValue="focus" decimalPlaces="0"
placeholder="£ " disabled="#{c.restored eq 'false' or c.restored eq null}">
<p:ajax event="change" />
</p:inputNumber>
</td>
</tr>
</ui:repeat>
</tbody>
</table>
</p:outputPanel>