p:dataTable找不到记录

时间:2015-07-04 15:48:05

标签: jsf primefaces datatable jsf-2.2

我在对话框中有一个数据表。

当用户点击<h:form> <h:dataTable value="#{messageBean.messagesList}" var="msg"> <h:column> <f:facet name="header">Detail</f:facet> <p:commandLink action="#{messageBean.fetchSelectedMessage(msg.msgId)}" value="#{msg.summary}" /> </h:column> </h:dataTable> </h:form> 链接时,应显示带有数据表的对话框。

以下是代码:

messageBean.fetchSelectedMessag(...)

这是@ManagedBean @SessionScoped public class MessageBean { ... private List<Messages> messagesList; private List<Messages> selectedMessage; public void fetchSelectedMessage(String msgId) { String sql = "SELECT * FROM messages WHERE msgId=?"; selectedMessage = jdbcTemplate.query(sql, new Object[]{msgId}, new BeanPropertyRowMapper<Messages>(Messages.class)); System.out.println("fetched selected message== " + selectedMessage); //correct //open dialog sucucessfully RequestContext context = RequestContext.getCurrentInstance(); context.execute("PF('dlg1').show();"); } //getter/setters

<p:dialog widgetVar="dlg1" modal="true" height="100">
    <p:dataTable var="msg1" value="#{messageBean.selectedMessage}">

        <p:column headerText="id">
            <h:outputText value="#{msg1.msgId}"/>
        </p:column>

        <p:column headerText="to person">
            <h:outputText value="#{msg1.toPerson}"/>
        </p:column>

    </p:dataTable>

</p:dialog>

然后应打开此对话框(并成功打开,但不显示任何内容)

selectedMessage

为什么对话框数据表不能显示任何内容?

messages<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" tools:context=".MainActivity"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" style="@style/toolbarStyle" android:layout_width="match_parent" android:layout_height="57dp" app:layout_scrollFlags="scroll|enterAlways"> <RelativeLayout android:id="@+id/focusHolder" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" android:focusableInTouchMode="true" android:paddingBottom="10dp" android:paddingTop="10dp"> <Button android:id="@+id/tmpBtn" android:layout_width="48dp" android:layout_height="match_parent" android:layout_alignParentRight="true" android:background="@null" /> <EditText android:id="@+id/addressBar" style="@style/addressBarStyle" android:layout_width="match_parent" android:layout_height="30dp" android:layout_centerVertical="true" android:layout_toLeftOf="@id/tmpBtn" android:imeOptions="actionGo" android:singleLine="true" /> </RelativeLayout> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/darkGreen" android:fillViewport="true" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <RelativeLayout android:id="@+id/webViewWrapper" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/yellow"> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> </RelativeLayout> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout> <!-- Nav drawer --> <fragment android:id="@+id/navigation_drawer" android:name="com.example.fastbrowser.NavigationDrawerFragment" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" android:layout_marginTop="57dp" tools:layout="@layout/fragment_navigation_drawer" /> </android.support.v4.widget.DrawerLayout> 类型的列表,不为空。

1 个答案:

答案 0 :(得分:0)

每次点击后都需要更新对话框:

<p:commandLink ... process="@this" update=":msgForm:dlgPanel" onComplete="PF('dlg1').show();"/>