Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在JSF页面中单击行时如何打开新页面?_Java_Javascript_Jsf_Jsf 2 - Fatal编程技术网

Java 在JSF页面中单击行时如何打开新页面?

Java 在JSF页面中单击行时如何打开新页面?,java,javascript,jsf,jsf-2,Java,Javascript,Jsf,Jsf 2,我有一个JSFh:datatable,其中包含数据行: <h:dataTable id="dataTable" value="#{SessionsController.dataList}" binding="#{table}" var="item"> <!-- Check box --> <h:column> <f:face

我有一个JSF
h:datatable
,其中包含数据行:

  <h:dataTable id="dataTable" value="#{SessionsController.dataList}" binding="#{table}" var="item">
                    <!-- Check box -->
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Select" />
                        </f:facet>
                        <h:selectBooleanCheckbox  onclick="highlight(this)" value="#{SessionsController.selectedIds[dataItem.id]}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="№" actionListener="#{SessionsController.sort}">
                                <f:attribute name="№" value="№" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{table.rowIndex + SessionsController.firstRow + 1}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="Account Session ID" actionListener="#{SessionsController.sort}">
                                <f:attribute name="sortField" value="Account Session ID" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{item.aSessionID}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="User ID" actionListener="#{SessionsController.sort}">
                                <f:attribute name="sortField" value="User ID" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{item.userID}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="Activity Start Time" actionListener="#{SessionsController.sort}">
                                <f:attribute name="sortField" value="Activity Start Time" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{item.activityStart}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="Activity End Time" actionListener="#{SessionsController.sort}">
                                <f:attribute name="sortField" value="Activity End Time" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{item.activityEnd}" />
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:commandLink value="Activity" actionListener="#{SessionsController.sort}">
                                <f:attribute name="sortField" value="Activity" />
                            </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{item.activity}" />
                    </h:column>
                </h:dataTable>
问题是我需要一个JSF标记,当单击行并传递数据时,JavaScript将使用该标记打开新页面。在本例中,href用于导航到新窗口。我需要JSF标签,它可以用于相同的目的。有合适的JSF标签吗


最好的祝愿

您可以使用纯HTML




与具体问题无关至于jQuery选择器,不要忘记考虑JSF将客户机ID与父命名容器组件的ID放在一起。检查生成的HTML输出以确保。

是否有其他方法打开新页面?例如,当我单击一行从托管bean调用Java方法时,是否可能。Java方法将返回例如“123acb”。我将在faces-config.xml中将其配置为一个导航规则。例如,使用PrimeFaces'
更容易。同样,我更喜欢使用纯JSF。你能想出任何可能的方法来实现我的目标吗?是的,但是我已经花了很多时间来实现JSF页面,我不想重新开始。是否可以使用这个标签洞察我的代码?您需要自己编写一些JS代码,就像使用jQuery一样。您可以通过JS/jQuery提交隐藏表单来调用bean操作方法。
   $("table#dataTable tbody tr").click(function () {
            window.location = $(this).find("a:first").attr("href");
        });