# 4
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<ui:page binding="#{restricted$admin$Classes.page1}" id="page1">
<ui:html binding="#{restricted$admin$Classes.html1}" id="html1">
<ui:head binding="#{restricted$admin$Classes.head1}" id="head1">
<ui:link binding="#{restricted$admin$Classes.link1}" id="link1" url="/resources/stylesheet.css"/>
</ui:head>
<ui:body binding="#{restricted$admin$Classes.body1}" id="body1">
<ui:form binding="#{restricted$admin$Classes.form1}" id="form1">
<ui:table augmentTitle="false" binding="#{restricted$admin$Classes.table1}" id="table1" title="Tanımlı Dersler" width="636">
<f:facet name="actionsTop">
<ui:panelGroup binding="#{restricted$admin$Classes.groupPanel1}" id="groupPanel1">
<ui:button action="#{restricted$admin$Classes.addClass_action}" binding="#{restricted$admin$Classes.addClass}"
id="addClass" text="Ekle"/>
<ui:button action="#{restricted$admin$Classes.cancelClass_action}" binding="#{restricted$admin$Classes.cancelClass}"
id="cancelClass" text="İptal"/>
<ui:button action="#{restricted$admin$Classes.saveClass_action}" binding="#{restricted$admin$Classes.saveClass}"
id="saveClass" text="Kaydet"/>
</ui:panelGroup>
</f:facet>
<script><![CDATA[
/* -- Functions for Table Preferences Panel -- */
/*
* Toggle the table preferences panel open or closed
*/
function togglePreferencesPanel() {
var table = document.getElementById("form1:table1");
table.toggleTblePreferencesPanel();
}
/* -- Functions for Filter Panel -- */
/*
* Return true if the filter menu has actually changed,
* so the corresponding event should be allowed to continue.
*/
function filterMenuChanged() {
var table = document.getElementById("form1:table1");
return table.filterMenuChanged();
}
/*
* Toggle the custom filter panel (if any) open or closed.
*/
function toggleFilterPanel() {
var table = document.getElementById("form1:table1");
return table.toggleTableFilterPanel();
}
/* -- Functions for Table Actions -- */
/*
* Initialize all rows of the table when the state
* of selected rows changes.
*/
function initAllRows() {
var table = document.getElementById("form1:table1");
table.initAllRows();
}
/*
* Set the selected state for the given row groups
* displayed in the table. This functionality requires
* the 'selectId' of the tableColumn to be set.
*
* @param rowGroupId HTML element id of the tableRowGroup component
* @param selected Flag indicating whether components should be selected
*/
function selectGroupRows(rowGroupId, selected) {
var table = document.getElementById("form1:table1");
table.selectGroupRows(rowGroupId, selected);
}
/*
* Disable all table actions if no rows have been selected.
*/
function disableActions() {
// Determine whether any rows are currently selected
var table = document.getElementById("form1:table1");
var disabled = (table.getAllSelectedRowsCount() > 0) ? false : true;
// Set disabled state for top actions
document.getElementById("form1:table1:tableActionsTop:deleteTop").setDisabled(disabled);
// Set disabled state for bottom actions
document.getElementById("form1:table1:tableActionsBottom:deleteBottom").setDisabled(disabled);
}]]></script>
<ui:tableRowGroup binding="#{restricted$admin$Classes.tableRowGroup1}" emptyDataMsg="Herhangi bir kayıt bulunamadı"
id="tableRowGroup1" rows="10" sourceData="#{restricted$admin$Classes.classesDataProvider}" sourceVar="currentRow">
<ui:tableColumn binding="#{restricted$admin$Classes.tableColumn1}" headerText="Ders Kodu" id="tableColumn1">
<ui:staticText binding="#{restricted$admin$Classes.staticText1}" id="staticText1"
text="#{currentRow.value['classes.class_id']}" visible="#{!restricted$admin$Classes.visible}"/>
<ui:staticText binding="#{restricted$admin$Classes.staticText2}" id="staticText2"
style="color: red; font-weight: bolder" text="Yeni" visible="#{restricted$admin$Classes.visible}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{restricted$admin$Classes.tableColumn2}" headerText="Ders Adı" id="tableColumn2">
<ui:textField binding="#{restricted$admin$Classes.textField1}" id="textField1" readOnly="true" text="#{currentRow.value['classes.class_name']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{restricted$admin$Classes.tableColumn3}" headerText="Zorunlu/Se鏼eli" id="tableColumn3">
<ui:dropDown binding="#{restricted$admin$Classes.dropDown1}" id="dropDown1"
items="#{restricted$admin$Classes.objectArrayDataProvider1.array}" selected="#{currentRow.value['classes.compulsory_elective']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{restricted$admin$Classes.tableColumn4}" headerText="Ders Saati" id="tableColumn4" width="246">
<ui:textField binding="#{restricted$admin$Classes.textField2}" id="textField2" text="#{currentRow.value['classes.hours']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{restricted$admin$Classes.tableColumn5}" headerText="Karne Sırası" id="tableColumn5">
<ui:textField binding="#{restricted$admin$Classes.textField3}" id="textField3" text="#{currentRow.value['classes.karne_rownumber']}"/>
</ui:tableColumn>
</ui:tableRowGroup>
</ui:table>
<ui:messageGroup binding="#{restricted$admin$Classes.messageGroup1}" id="messageGroup1"/>
</ui:form>
</ui:body>
</ui:html>
</ui:page>
</f:view>
</jsp:root>
The readonly attribute of ui:textfield whose id textfield1 is set to true. The tableRowGroup is bound to a CachedRowSetDataProvider. When I run the program, I got the wrong data as I mentioned earlier. In addition, I downloaded the source code of Sun Web UI Components Design-Time Support, that is webui.jar, and debugged the program. What I noticed is that getReadOnlyComponent method of Field class is the source of the bug since the method getFacet(READONLY_FACET); of the code below returns the very first component so the value of the ReadOnly textfield for each row is the very first data read from the database.
// Readonly value
public UIComponent getReadOnlyComponent(FacesContext context) {
if(DEBUG) log("getListLabelComponent()");
String id = getId();
// Check if the page author has defined a label facet
UIComponent textComponent = getFacet(READONLY_FACET); //NOI18N
// If the page author has not defined a label facet,
// check if the page author specified a label.
if(textComponent == null) {
textComponent = createText(getReadOnlyValueString(context)); //NOI18N
} else if(DEBUG) {
log("\tFound facet."); //NOI18N
}
return textComponent;
}