尝试使用JSF和Primefaces为Yes / No / NA / Resolved清单重构以下JSP版本:
<c:forEach var="qAndA" items="${checklist.answer_attribute_list}">
..trim..
<td class="chklist"><input type="radio" name="radio_<c:out value="${qAndA.attribute_id}" />" onclick="this.form.no_<c:out value="${qAndA.attribute_id}" />.disabled=true;this.form.no_<c:out value="${qAndA.attribute_id}" />.style.backgroundColor='#808080';" value="1"></td>
<td class="chklist"><input type="radio" name="radio_<c:out value="${qAndA.attribute_id}" />" onclick="this.form.no_<c:out value="${qAndA.attribute_id}" />.style.backgroundColor='#ffffff';this.form.no_<c:out value="${qAndA.attribute_id}" />.disabled=false;" value="2"></td>
<td class="chklist"><textarea DISABLED onkeyup="sz(this);" style="background:#808080" name="no_<c:out value="${qAndA.attribute_id}" />" cols=19 rows="4" onkeypress="if(this.value.length>499){ alert('You have exceeded the limit of 500 characters. Please edit your entry.'); return false}"></textarea></td>
<td class="chklist"><input type="radio" name="radio_<c:out value="${qAndA.attribute_id}" />" onclick="this.form.no_<c:out value="${qAndA.attribute_id}" />.disabled=true;this.form.no_<c:out value="${qAndA.attribute_id}" />.style.backgroundColor='#808080';" value="3"></td>
<td class="chklist"><input type="checkbox" DISABLED name="check_<c:out value="${qAndA.attribute_id}" />" value="4"></td>
列标题在图像中被截止但它们是:
Q号|问题|部分|是的|没有|没有原因| N / A |解决?
使用旧的JSP,如果用户点击了&#34; no&#34;收音机,它将允许他们输入&#34; No Reason&#34;但如果他们改变主意,他们仍然可以点击“是”#34;或者&#34; n / a&#34;收音机和&#34; No Reason&#34;文本框将灰显并禁用。在用户点击提交按钮之前,无线电值并没有真正改变,所以在他们点击了#34;否&#34;之前,已解决的复选框没有出现。并提交了表格。
但是对于JSF和数据表,我不知道如何像在旧的Jsp中那样引用每行中的textareas。所以基于BalusC的帮助,这篇帖子提供了数量类型核对表JSF disable inputbox with a checkbox in a ui:repeat on a composite component我使用Ajax尝试了以下JSF:
<p:dataTable id="dataTable" value="#{cc.attrs.checklist.answer_attribute_list}" var="qAndA">
<p:column headerText="Yes" width="50px;">
<p:selectOneRadio id="yesNoNA" value="#{qAndA.toggle_value}" layout="custom">
<f:selectItem itemLabel="Yes" itemValue="1" />
<f:selectItem itemLabel="No" itemValue="2" />
<f:selectItem itemLabel="NA" itemValue="3" />
<f:selectItem itemLabel="Resolved" itemValue="4" />
<p:ajax update="@form" />
</p:selectOneRadio>
<p:radioButton id="yes" for="yesNoNA" itemIndex="0" rendered="#{empty qAndA.toggle_value or qAndA.toggle_value == '0'}" />
<h:outputText value="X" rendered="#{qAndA.toggle_value == '1'}" />
<h:outputText value="" rendered="#{qAndA.toggle_value == '2' or qAndA.toggle_value == '3' or qAndA.toggle_value == '4'}" />
</p:column>
<p:column headerText="No" width="50px;">
<p:radioButton id="no" for="yesNoNA" itemIndex="1" rendered="#{empty qAndA.toggle_value or qAndA.toggle_value == '0'}" />
<h:outputText value="X" rendered="#{qAndA.toggle_value == '2' or qAndA.toggle_value == '4'}" />
<h:outputText value="" rendered="#{qAndA.toggle_value == '1' or qAndA.toggle_value == '3'}" />
</p:column>
<p:column headerText="Reason For Attribute Failure" width="250px;">
<h:inputTextarea value="#{qAndA.fail_reason}" rendered="#{qAndA.toggle_value == '2'}" />
<h:outputText value="#{qAndA.fail_reason}" rendered="#{empty qAndA.toggle_value or qAndA.toggle_value == '0'}" />
<h:outputText value="" rendered="#{qAndA.toggle_value == '1' or qAndA.toggle_value == '3'}" />
<h:outputText value="#{qAndA.fail_reason}" rendered="#{qAndA.toggle_value == '2' or qAndA.toggle_value == '4'}" />THIS ONE IS REDUNDANT
</p:column>
<p:column headerText="N/A" width="50px;">
<p:radioButton id="na" for="yesNoNA" itemIndex="2" rendered="#{empty qAndA.toggle_value or qAndA.toggle_value == '0'}" />
<h:outputText value="X" rendered="#{qAndA.toggle_value == '3'}" />
<h:outputText value="" rendered="#{qAndA.toggle_value == '1' or qAndA.toggle_value == '2' or qAndA.toggle_value == '4'}" />
</p:column>
<p:column headerText="Resolved *" width="75px;">
<p:radioButton id="resolved" for="yesNoNA" itemIndex="3" rendered="#{qAndA.toggle_value == '2'}"
disabled="#{qAndA.toggle_value != '2'}" />
<h:outputText value="" rendered="#{qAndA.toggle_value == '1' or qAndA.toggle_value == '3'}" />
<h:outputText value="X" rendered="#{qAndA.toggle_value == '4'}" />
</p:column>
Ajax的问题是它会立即更改值,导致表单的行为与jsp不同。我不确定如何继续,这对Ajax来说是否可行。
我也一直在玩更具体的渲染和更新
<f:ajax render=":dataTable:2:texa"/>
<p:ajax update="how to reference specific row" />
找不到带表达式的组件&#34;:texa&#34;引自&#34; j_idt19:j_idt48:0:j_idt99:j_idt101:dataTable:2:texa&#34;。
j_idt19:j_idt48:0:j_idt99:j_idt101:dataTable中:ROWID:COMPONENT