1

Liferay 検索コンテナを使用してデータベースから取得した行を無効にする必要があります。データベースに特定の条件が保存されています。

私が達成したいのはこれです:

  1. 出席をマークする必要がある学生のリストを表示しています。
  2. 場合によっては、学生が事前に休暇を取ることがあります。その場合、出席はデータベースで事前にマークされます。
  3. そのため、出席をマークするためのフォームが表示されたときに、出席が既にマークされている学生のデータを含む行を無効にすることで、出席のマークを無効にしたいと考えています。

私がやりたいことは、出席が事前にマークされている場合、フォームに事前にマークされた出席のある行を表示し、ユーザーがその学生の出席をマークできないようにすることです。つまり、行を無効にします。

どうすればこれを達成できますか?

編集: コード スニペット

    Mark Attendance for Today:   
    <%=new java.util.Date()%>

    <portlet:actionURL name="updateAtt" var="updateAttURL" />

        <aui:form name="updateAtt" action="<%=updateAttURL.toString() %>" method="post" >

            Choose Date to mark Attendance:
            <liferay-ui:input-date formName="attendanceDate" yearRangeStart="<%=year %>" yearRangeEnd="<%=year %>"
                    yearValue="<%=year %>" monthValue="<%=month %>" dayValue="<%=day %>" 
                    dayParam="datt" monthParam="matt" yearParam="yatt" />

            <portlet:renderURL  var="viewstudentDataURL"/>

            <liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">

                <liferay-ui:search-container-results total="<%= studentAttendanceDetails .size() %>"
                        results="<%= ListUtil.subList(studentAttendanceDetails , searchContainer.getStart(), searchContainer.getEnd()) %>" />
                <liferay-ui:search-container-row modelVar="search"
                    className="com.corpserver.mis.portal.model.Student">   

                    <%
                    String LImageId = String.valueOf(search.getFileEntryId());
                    long ImageId = Long.valueOf(LImageId);
                    DLFileEntry image = DLFileEntryLocalServiceUtil .getFileEntry(ImageId ); 
                    String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();
                    %>

                    <liferay-ui:search-container-column-text name="student Photo" href = "">
                        <img src="<%=imageURL%>" height="50" width="50"/> 
                    </liferay-ui:search-container-column-text>
                    <!-- Code to display student Image -->

                    <%
                    String eol = System.getProperty("line.separator");
                    %>

                    <liferay-ui:search-container-column-text name='student Name' value='<%=String.valueOf(search.getstudentFname()) +  String.valueOf(search.getstudentLname()) + "<br>" + String.valueOf(search.getstudentTitle()) %>'  href="" >

                    </liferay-ui:search-container-column-text>

                    <liferay-ui:search-container-column-text name="Attendance Status">                       
                        <label>Present</label><input type = "radio" name ='updateattendance<%=String.valueOf(search.getstudentId())%>' value = "Present" />
                        <label>Absent</label><input type = "radio" name= 'updateattendance<%=String.valueOf(search.getstudentId())%>' value = "Absent"/>
                    </liferay-ui:search-container-column-text>

                </liferay-ui:search-container-row>

                <liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true %>" />
            </liferay-ui:search-container>

            <input type = "submit" value = "Update"/>
        </aui:form>
</body>
</html>
4

1 に答える 1

1

次のように、条件ステートメントを使用して、入力コントロールの代わりにラベルを表示するか、入力コントロールを無効にすることができます。

<%
String LImageId = String.valueOf(search.getFileEntryId());
long ImageId = Long.valueOf(LImageId);
DLFileEntry image = DLFileEntryLocalServiceUtil .getFileEntry(ImageId ); 
String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();

// you can define a flag for the pre-marked attendance
boolean preMarkFlag = isStudentPreMarked(); // have value true (student is premarked) or false (if the student is not pre-maked)    
%>

<liferay-ui:search-container-column-text name="Attendance Status">
    <label>Present</label>
    <input type = "radio"
            name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
            value = "Present"
            <%= preMarkFlag ? "disabled" : "" %> />

    <label>Absent</label>
    <input type = "radio"
            name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
            value = "Absent"
            <%= preMarkFlag ? "disabled" : "" %> />
</liferay-ui:search-container-column-text>

または別の方法は、ラベルを表示するだけで、入力ラジオボタンをまったく表示しないことです

<liferay-ui:search-container-column-text name="Attendance Status">
    <%
    // I am assuming if preMarkFlag is true then the student is absent
    // as mentioned in your question
    if (preMarkFlag) {
    %>

    <label>Absent</label>

    <%
    } else {
    %>

    <label>Present</label>
    <input type = "radio"
            name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
            value = "Present"
            <%= preMarkFlag ? "disabled" : "" %> />

    <label>Absent</label>
    <input type = "radio"
            name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
            value = "Absent"
            <%= preMarkFlag ? "disabled" : "" %> />

    <%
    }
    %>
</liferay-ui:search-container-column-text>        
于 2013-05-13T09:48:58.653 に答える