Jsf pages from entities

0

WhenIgeneratethejsfpagesfromentitiesclassbynetbeans,itautomaticallygeneratesthedatabasecrudinprimefacesifIprefer,butwhenIputsometablethathasrelationwithforeignkey,atthetimeofregisteringittakesthefieldinthiswaythroughaselectOneMenu(entitiesProductValue[idVend=2]),whereittakesthepath+theidofthefield,andassignstheidandmakestheregistrationaccordingtotheid,Iwanttodoforitgetthenameofthefieldandinserttheid,ieintheselectOneMenuwillbepresentedthenamewhenselectwillregistertheidofthatname.

<p:selectOneMenuid="idUsu" value="#{vendaProdutoController.selected.idUsu}" >
                        <f:selectItems value="#{usuarioController.itemsAvailableSelectOne}"
                                       var="idUsuItem"
                                       itemValue="#{idUsuItem}"/>
                    </p:selectOneMenu>

I tried to do this as follows, where it accesses the following path: salesProductController.selected.Product.ProductName, which in my logic took the product name, but in selectOne it appears empty.

<p:selectOneMenu id="idUsu" value="#{vendaProdutoController.selected.idUsu}" >
                        <f:selectItems value="#{vendaProdutoController.selected.idProduto.nomeProduto}"
                                       var="idUsuItem"
                                       itemValue="#{idUsuItem}"/>
                    </p:selectOneMenu>

How do I get selectOneMenu to display the name correctly?

    
asked by anonymous 18.06.2016 / 20:49

1 answer

0

You need to use the f: SelectedItems attribute "itemLabel", in it you can use an expression, using var to write whatever you want. Example:

Note that in your selectOneMenu the value must be of the type of your itemValue.

    
18.06.2016 / 21:06