• Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic form in BEA porlet  RSS feed

Lam Le
Posts: 3
  • Mark post as helpful
  • send pies
  • 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="{actionForm.jobs}"/>
<%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(){
this.jobs.add(new 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!