aspose file tools*
The moose likes JSF and the fly likes how to get id of many many list within ace:dialog and c:foreach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "how to get id of many many list within ace:dialog and c:foreach" Watch "how to get id of many many list within ace:dialog and c:foreach" New topic
Author

how to get id of many many list within ace:dialog and c:foreach

Harini nataraj
Greenhorn

Joined: Jan 10, 2012
Posts: 10
have some thing like this, it would be great if i got some help.

<c:forEach items="${gapMatch.text}" var="fill" >
<iceutputText value="${fill.outputText}" />
<ice:inputText onclick="popup.show();"
rendered="${fill.textflag}" />
<ace:dialog header="Select" widgetVar="popup" closable="true"
modal="true" draggable="false" position="center">
<ice:panelGroup styleClass="selectionListBoxGroup">
<ice:selectManyListbox id="${fill.inputText}" value="${fillupresponse.userSelected}"
valueChangeListener="${gapMatch.valueChanged}"
partialSubmit="true">
<f:selectItems value="${gapMatch.answertext}" />
</ice:selectManyListbox>
</ice:panelGroup>
</ace:dialog>
</c:forEach>



the ids for my selectmanylist are unique, i am getting this ids in managed bean but any change made i am getting the same id, that is last id which i assigned using c:foreach.. please help me out in getting each time new id based on user selection. onclick of my text box popup opens and for each text box i have each select many list based on which i can know which text box user selected.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Don't use JSTL. JSTL does not work well with JSF. JSTL doesn't understand JSF, and it was designed for a completely different way of rendering pages.

To repeat a UI element using native JSF (without JSTL), either use the datatable container tag (recommended), or, for cases when a tabular payout isn't desirable, the ui:repeat facelets tag. And when I say "tabular layout isn't desirable", I don't mean because some idiot has declared that tables are forbidden and that only <div>'s should be used. This is JSF, not HTML, and you actually shouldn't be coding raw HTML in JSF anyway, therefore you shouldn't be coding <div>'s. If it looks like a table on the screen, use the table tag. And the whole div/table thing was just silly, even in raw HTML.

Almost forgot. In JSF, there are two id's. The short ID is the one you code on the JSF tag. This typically generates a longer qualified ID in the resulting raw HTML. JSF objects use the short ID, but javascript has to use the long ID. For more on why there are 2 IDs, look up the term "JSF Naming Container".


Customer surveys are for companies who didn't pay proper attention to begin with.
Harini nataraj
Greenhorn

Joined: Jan 10, 2012
Posts: 10

i have tried this also but same problem
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

I added Code tags to your example because I couldn't read the text after our message formatter got done chewing it up. Code tags can be added using the "Code" button on the message editor, and they're useful for any sort of pre-formatted text: java code, XML, Visual Basic , whatever.

I think you're not fully aware of what an "id" is. "id" is an XML attribute with special properties. An ID must be unique within the XML. JSF automatically generates (unpredictable) id names on output xhtml if you didn't explicitly supply one on the original source. It also adds qualifiers, since the output xhtml doesn't have a 1-to-1 element correspondence to the input VDL.

One thing that you cannot do, however, is define an ID as an EL expression. The id value must be a text constant value. Also, as a general rule, you shouldn't be using the "$" notation for EL, since it has a more limited functionality than the "#" notation. But neither of them can be used for an ID.

In your example, there's no need to make the ID a variable expression anyway. Just code "id="mySelectMany"" and be done with it.


Harini nataraj
Greenhorn

Joined: Jan 10, 2012
Posts: 10
Hi Tim,

Thank You for your explanation, I am using unique ID for each of my input Text from my Bean Class and again i need this id back to my bean i mean the user selected id to perform some operation and also to identify which component user selected, but my main main problem is i cant use any command button in UI, if i have used that i would have got these id easily in my bean on some action. only thing what i can do is on selection of any values within my SelectManyListBox i have to get this id in my bean so that i can display the user selection in my inputtext, no problem where i keep the dialog that is may be within c:foreach or outside the loop. I am really struck here and am planning to use Javascript now, but i havent succeed still. Any idea or suggestion is really appreciated.



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

You need to find a good book on basic JSF. JSF is designed to make stuff like this easy and you're attempting to do things hard. JSF is not just JSP's re-written, it's a true Model/View/Controller implementation, which is why I'm so assertive about not putting code in the View definition. In JSF, views are designed to be used as templates, not as executable objects the way that JSPs are.

You do not need to know the component ID in your server-side code. JSF knows perfectly well which component instance goes with which model row when you do things properly without you having to tell it. And, in fact it's very bad practice to code View dependencies into the Model object.

Most definitely you do need to get rid of all those "${}" expressions. The "$" form is read-only and a lot of JSF EL requires read/write references. The read/write expression syntax uses "#{}".

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get id of many many list within ace:dialog and c:foreach