在下面的代码(jsf页面)中,我在display:table行中有一些酒店信息,但我想将房间详细信息作为表填充到主表的一列中。代码实际上更有意义。在标题为"Rooms“的列中,我想显示一个包含房间详细信息的表。整个表使用一个名为"suitableHotelsList“的列表。在该列表中,有几个mainVO,它们包含列属性中的详细信息。此外,roomList (包含roomVO)也在MainVO中。因此,我假设我应该能够做一个新的表,如下所示,但给出错误“未知属性'roomList'”有什么建议,我可以做什么,以联系酒店和他们的房间?
<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>/>
<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}&screenType='O'&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}&screenType='O'&initial='true'">
<ui:image style="height:80px; width:80px;" url="/resources/img3.JPG"/>
</a>
</display:column>
</display:table>
</display:column>
</display:table>
</div>发布于 2012-01-06 17:10:15
外层的表有id="hotelList"。这意味着在迭代期间,标签允许您使用页面范围属性"hotelList“访问当前的酒店列表。因此,我将其命名为“酒店”,这将使它更清晰。
您需要访问当前酒店的房间列表。您使用requestScope.DetailSelection.suitableHotelsList.roomList来做这件事,这是没有意义的:酒店列表(我猜是java.util.List类型)没有任何名为"roomList“的属性。相反,您希望访问当前酒店的房间列表:hotel.roomList (假设您已经按照上面的建议将hotelList重命名为酒店)。
此外,嵌套表使用ID roomList。和上面一样:将它命名为"room“会容易得多。迭代中的当前对象是房间,而不是房间列表。
最后,另一个问题是id属性还用于设置内部HTML表的ID属性。由于ID对于整个HTML页面应该是唯一的,并且您将有几个内部表,这将导致无效的HTML。因此,您还应该将htmlId属性设置为唯一的属性,如room${hotel_rowNum}。有关标签参考,请参见http://www.displaytag.org/1.2/displaytag/tagreference.html。
https://stackoverflow.com/questions/8755414
复制相似问题