Hello all! First time poster and rest assured that I've used the search functionality on Nabble to see if there are similar problems to mine, and I haven't yet stumbled across my own use case yet (and I find that to be a huge surprise!).
Anyway, I want to state my problem in a precise and unambiguous manner so I can help you guys help me! Problem Statement: <loop/> constructs to not seem to make it possible to add varied numbers of <select/> elements to a form. Use Case: I am writing a web application that calls a SOAP service. Inside the soap calls, I can pick from a variable number of a certain kind of information. The information I am getting from SOAP is well ordered for use with <select/> elements. Each one has an ID and a certain amount of text associated with it. These are questions that the user will answer. The application must be configurable viz. the number of questions that will be asked the user. Each <select/> element will have an <input/> associated with it, to collect the user's answer to the question. Therefore, you can see how a fixed number of <select/> elements is not feasible; Some consumers of the app will want to ask the user one question, some five! Therefore I need to be able to display a variable number of these questions on the page. Notes: * I am getting the questions from a SOAP service. I don't have a database/hibernate/JPA or anything else. Therefore all the questions for each "group" are in a fixed array (or ArrayList; it does not matter at all). * The question ID is the value for each item in the <select/> with the question text being the "label" I guess. Therefore, what I need to pass back is the question ID and the user answer for each group. End Result Desired: * A form, with a number of paired <select/> elements and <input/> elements, representing a questions asked of the user and their answer. * The number of these pairs is not known until I query the SOAP service and receive back a response containing a number of groups, each one of which will be a new <select/> element. * Upon submitting the form, my application has 'n' number of questionID/answer pairs that I then respond back to the SOAP service with. What I have Tried: Swing and Miss: I created a custom SelectModel for the objects that I received from the database. At runtime, I create one model for each group of questions I receive from the SOAP service. I then added each of these SelectModels to an ArrayList, making that ArrayList a @property in the class: @property private List<SelectModel> _questionSelectModels; // This is never null; it's populated during onPrepareForRender(); @property private SelectModel _currentModel Here is my Template: <form t:type="form" t:id="questionsEnrollForm"> <loop t:source="questionSelectModels" t:value="currentModel" t:formState="ITERATION"> Question: <select t:type="select" t:id="selected" t:value="selectedQuestionId" t:model="${currentModel}" /> </loop> <input type="submit" value="submit"/> </form> Result: Exception: Render queue error in BeforeRenderTemplate[Enroll:selectedquestionid]: Parameter 'model' of component Enroll:selectedquestionid is bound to null. This parameter is not allowed to be null. Why does confusion result on my part? * Because I assumed Tapestry would be able to iterate through the array list ----- Questions/comments: * I am surprised that this use case has never come up; Struts, for example, has a very elegant way of handling this (even though I hate everything else about it) * I know your time is valuable; I have tried to do my due diligence and have searched the mailing list and have come up with pretty much nothing on this. * Is it valid to attempt to iterate through a collection of SelectModel objects? * IS there a "best Practice" for what I'm trying to do? * How have others on this list handled this same use case? * I am suspecting that I have some sort of gross conceptual error about how this is supposed to work, but honestly for the life of me, I don't understand where it is. * I've combed the different tutorials avaialble as well. * One possible area I can tell would go wrong is in the select box's "value"; obviously each <select/> would attempt to update the same value! * Why is it not possible to have some sort of iterator variable to identify what to update? Please let me know if more source code form my end is needed to clarify what I'm doing wrong. Thank you so much for any help you can offer! --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org