Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

dynamic form in BEA porlet

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am doing in a project about bea portlet using page flow.
I had problems with dynamic form using netui-data:repeater tag.
I have a variable (jobs) of type java.util.List, each element (job) is a String. I want to populate this list in my form so that i can increase or decrease it if i want.
I did make a similar thing in struts app, I can use logic:iterate tag to iterate this list and use javascript to increase or decrease the size of the list. The trick here is that I use id to change the name of each member:
<logic:iterate name="form" property="jobs" id="job" type="java.lang.String">
this function will populate a list like this
and I can use this function to get list again:
public getJob(in index){
jobs.add(new String());
But with bea I can not do this thing. DO in with the netui-data:repeater tag it will generate
and I can not use function getJob(int index) again.
I know that there is one way in bea to make it worked. That is reloading the page and add a new String to that list. However as I use much javascript, I can not do like that. I have to keep the same page.
I did think about 2 walking arounds:
1. First i define the list in jsp page
<netui-data:getData resultId="jobs" value="{}"/>
<%List jobs=(List)pageContext.getAttribute("jobs");%>
I use when I click button "add", it will generate javascript code to add new row, and in the same time i will but 1 netui tag inside javascript code to increase the size of that list
//function add rows
jobs.add(new String());
This does not work as the size of the list only increase once.
2. In function getJobs I add new element

public List getJobs(){ String());
return jobs;
By doing this, before get any element, it will increase the size of list jobs first. Then later i will cast out Strings which have nothing, just keep elements having content. This works but i do not satisfy with this solution.
3. Im thinking about keep a global variable somewhere (int size=0;) and each time I add a new row, i will call size++ as well. DOing like this, 'size' will have a value which is equal to the size of that list. Then In function reset of the form:
public void reset(ActionMapping mapping, HttpServletRequest request) {
form=new FormBean();
for (int i=0;i<size;i++)
form.getJobs.add(new String());
then new Form can be populated. But it still does not work yet.
Can you please hellp me with this issue.
Thanks a lot.
    Bookmark Topic Watch Topic
  • New Topic