开发者

SelectOneMenu + CommmandButton

Hi I have the follonwing selectOneMenu

<h:selectOneMenu value="#{modelsController.selected.idBrands}">
    <f:selectItems value="{brandsController.itemsAvailableSelectOne}" />
</h:selectOneMenu> <br/>

which is populated with all available brands in the bean.

And I would like to create a button that retrives the brand selected in the mentioned selectOneMenu and display the records in the bean filtered by the selection (what I mean, is that if the user selected, aBrand in 开发者_运维知识库the selectOneMenu all models from abrand will be shown in a datatable.

This is a simple CRUD jsf 2.0 with EcpliseLink.

Could somebody point me in the right direction? Thank you very much


Add a <h:form> and a <h:commandButton>:

<h:form>
    <h:selectOneMenu value="#{modelsController.selected.idBrands}">  
        <f:selectItems value="{brandsController.itemsAvailableSelectOne}" />  
    </h:selectOneMenu>
    <br />
    <h:commandButton value="submit" action="#{modelsController.submit}" />
</h:form>

And define an action method which fills the datatable list based on the selected item.

public String submit() {
    items = itemDAO.load(selected.getIdBrands());
}

And display it in the <h:dataTable> the usual way.

<h:dataTable value="#{modelsController.items}" ... >
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜