mechanicum
mechanicum

Reputation: 709

using display:table within display:table column?

In the code below (jsf page), i have some hotel info in display:table rows but i want to cram the room details as a table in one of the columns of the main table. The code actually makes more sense. In the column with title "Rooms", i want to display a table with room details. The whole table uses a list called "suitableHotelsList". Within the list, there are several mainVOs which houses the details in the column properties. Also the roomList (which contains roomVO) is within the MainVO. Hence i presumed i should be able to do a new table as below but gives error saying " Unknown property 'roomList'" Any suggestions for what i could do to relate hotels with their rooms?

                <div class="Tbl" style="border-width: 2px; border-style: solid; margin: 2px; font-size: 20px; height: 442px; left: 22px; top: 46px; overflow: scroll; position: absolute; width: 1268px; z-index: 1">
                        <display:table class="its" id="hotelList" name="requestScope.DetailSelection.suitableHotelsList" style="border-width: 2px; border-style: solid;">
                            <display:setProperty name="basic.empty.showtable" value="false"/>
                            <display:setProperty
                                name="basic.msg.empty_list">Gösterilecek bir kayıt bulunamadı</display:setProperty>/&gt;
                            <display:column
                                property="hotelName" style="font-size: 30px; width:200px; text-align:center;" title="Hotel Name"/>
                            <display:column property="hotelStars" style="font-size: 30px; width:100px; text-align:center;" title="Stars"/>
                            <display:column property="userRating" style="font-size: 30px; width:100px; text-align:center;" title="User Rating"/>
                            <display:column property="hotelSummary" style="font-size: 20px; width:500px; text-align:center;" title="Summary"/>
                            <display:column style="width:100px;" title="Hotel Details">
                                <a href="HotelDetailsPage.jsp?id=${hotelList.hotelID}&amp;screenType='O'&amp;initial='true'">
                                    <ui:image style="height:80px; width:80px;" url="/resources/img2.JPG"/>
                                </a>
                            </display:column>
                            <display:column style="width:100px;" title="Rooms">
                                <display:table class="its" id="roomList" name="requestScope.DetailSelection.suitableHotelsList.roomList">
                                    <display:column property="room_type" style="font-size: 10px; width:100px; text-align:center;" title="Room Type"/>
                                    <display:column property="price_per_night" style="font-size: 10px; width:100px; text-align:center;" title="Price Per Night"/>
                                    <display:column property="room_number" style="font-size: 10px; width:100px; text-align:center;" title="Room Number"/>
                                    <display:column style="width:100px;" title="Hotel Details">
                                <a href="Reservations.jsp?id=${roomList.roomID}&amp;screenType='O'&amp;initial='true'">
                                    <ui:image style="height:80px; width:80px;" url="/resources/img3.JPG"/>
                                </a>
                                </display:column>
                                </display:table>
                            </display:column>
                        </display:table>
                    </div>

Upvotes: 0

Views: 16778

Answers (1)

JB Nizet
JB Nizet

Reputation: 691715

The outer table has id="hotelList". This means that during the iteration, the tag lets you access the current hotel is the list using the page-scope attribute "hotelList". I would thus name it "hotel", which would make it much clearer.

You need to access the list of rooms of the current hotel. You use requestScope.DetailSelection.suitableHotelsList.roomList to do this, which makes no sense: the list of hotels (of type java.util.List, I guess) doesn't have any property named "roomList". Instead, you want to access the current hotel's room list: hotel.roomList (provided you have renamed hotelList to hotel as suggested above).

Also, the nested table uses the ID roomList. Same as above: naming it "room" would be much less confusing. The current object in the iteration is a room, not a room list.

Finally, another problem is that the id attribute is also used to set an ID HTML attribute to the inner HTML table. Since an ID should be unique for the whole HTML page, and you will have several inner tables, this will lead to invalid HTML. You should thus also set a htmlId attribute to something unique, like room${hotel_rowNum}. See http://www.displaytag.org/1.2/displaytag/tagreference.html for the tag reference.

Upvotes: 2

Related Questions