【问题标题】:PrimFacse Linkbutton doesn't work inside dataGridPrimFacse Linkbutton 在 dataGrid 中不起作用
【发布时间】:2013-06-05 03:43:56
【问题描述】:

大家早上好, 我有一个与 primfaces 控件有关的问题。 我在 dataGrid 中放置了一个 commandLink,但 commandLink 没有进入 action 方法。 我不知道为什么。所以你能帮我解决这个问题吗PLZ 这是代码

<f:view>
<h:form>
    <p:tabView style="width: 420px;">

        <p:tab title="Events">

            <p:dataGrid value="#{EventDataTable.model}" var="event"
                        paginator="true" rows="3" columns="1"
                        paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink}"  
                        paginatorPosition="bottom"
                        styleClass="ui-datagrid-no-border" 
                        >
                <p:fieldset style="width:285px;height:150px" legend="#{event.eventDto.title}">

                    <table>

                        <tr>
                            <td rowspan="5">
                                <p:graphicImage value="#{event.image}" />  
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                Title: <p:outputLabel id="title" value="#{event.eventDto.title}"/>
                            </td>
                        </tr>
                        <tr>

                            <td></td>
                            <td>
                                Date: <p:outputLabel id="date" value="#{event.eventDto.date}"/>
                            </td>

                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                Content: <p:outputLabel id="desc" value="#{event.eventDto.content}"/>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <p:commandLink value="View More" actionListener="#{EventDataTable.doSomething()}" ajax="false"/>

                            </td>
                        </tr>
                    </table>


                </p:fieldset>

            </p:dataGrid>
        </p:tab>
        </f:view>
</h:form>

这颗豆子

@ManagedBean(name="EventDataTable")
@RequestScoped
public class EventBean  implements Serializable{

 @PostConstruct
    public void initial() {
        try {
            System.out.println("test init");
            List<EventDto> eventDtos = event.findEventByUserId(2);
            List<EventWrapper> eventWrappers =  new EventConverter().convert(eventDtos);
            model = new ListDataModel<EventWrapper>(eventWrappers);
            System.out.println("the size=" + model.getRowCount());


        } catch (ApplicationException ex) {
            ex.printStackTrace();
        }

    }

    public EventBean() {
    }
 public void doSomething() {
        //Doing Redirection will be here
        System.out.println("The selected number is " + model.getRowIndex()+"*****************************");

    }
}

【问题讨论】:

  • 你应该显示一些你的bean的代码,与你的p:commandButton相关...你真的在JSF 1.2上吗? PrimeFaces 的版本是多少?
  • 我在您的表单中没有看到任何 p:commandLink。您的数据网格是否也正确获取值?如我所见,您的 bean 名称是大写的(EventDataTable)。最后,您是否尝试过调试它,该方法被执行,并且堆栈跟踪可能没有显示一些奇怪的 try/catch 机制?
  • 不好意思,现在我把有问题的代码放上去。
  • 我正在使用 Primfaces 3.2 和 JSF 2.1
  • @Yasmin 您应该包含 bean 的相关部分,即:至少声明(范围和名称)以及 doSomething()

标签: jsf jsf-2 primefaces java-ee-7


【解决方案1】:

您的 xhtml 中没有表单。将数据表包装在表单中

【讨论】:

  • 之前的xhtml中没有表格。
猜你喜欢
  • 1970-01-01
  • 2011-11-07
  • 2012-07-01
  • 1970-01-01
  • 2015-06-16
  • 2017-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多