-
1. Re: adding a new row
ilya_shaikovsky Jan 14, 2010 8:06 AM (in response to waq)http://in.relation.to/11633.lace - this case contains not the concrete code for yours case but I think clearly shows the way. In the thread tabs added dynamically on search, and in your case all is even simplier - just to add one more input on clicking some add button. -
2. Re: adding a new row
waq Jan 14, 2010 11:12 AM (in response to ilya_shaikovsky)is there any other way instead of using JSTL? -
3. Re: adding a new row
elf Jan 14, 2010 11:47 AM (in response to waq)In case of "another field called Topics" is table, may be it will be good to:
1. create ADD button on UI
2. call some bean action clicking this button
3. add new Topic class object to bean array (binded to UI table)
4. refresh table on complete this action
-
4. Re: adding a new row
waq Jan 15, 2010 11:28 AM (in response to elf)ok i did as:
.XHTML
<
a4j:outputPanel id="topics_panel">
<a4j:region id="topic_region">
<h:dataTable value="#{regesterCourse.topicList}" var="top">
<h:column>
<h:inputText id="course_topics"
value="#{top.topic}" size="20" />
</h:column>
</h:dataTable>
<a4j:commandButton value="A" reRender="topics_panel"
action="#{regesterCourse.addNewRow}"/>
</a4j:region>
<a4j:status for="topic_region" startText="Wait" stopText=""/>
</a4j:outputPanel>
.JAVA
public
topicList.add(new TopicList(""));
}
//end addNewRow()
but it adds only one row, even button calls the action everytime i hit it.
-
-
-
-
8. Re: adding a new row
nbelaevski Jan 17, 2010 11:27 AM (in response to waq)Use scope with longer lifetime, e.g. session or conversation. -
9. Re: adding a new row
waq Jan 17, 2010 12:01 PM (in response to nbelaevski)can t:saveState work for it? But why it still calls action on every button hit? -
10. Re: adding a new row
waq Jan 18, 2010 6:16 AM (in response to waq)ok i used a4j:keepAlive and it works for me but when i press submit button it thorws java.lang.IllegalStateException.
After debugging i came to know that exception is comming from the following .JAVA statement:
HttpSession session = (HttpSession)
context.getExternalContext().getSession(false);
-
11. Re: adding a new row
waq Jan 19, 2010 7:02 AM (in response to waq)any solution on this? i found that the issue occur because session got invalidated. but can't able to find the solution for this.
Moreover i am trying to provide a delete functionality to the user which allows the user to delete the current row. It works fine but it always delete the last row.
<
rich:dataTable value="#{regesterCourse.topicList}" var="top"
rowKeyVar="row">
<rich:column>
<h:inputText id="topic_list_fld" value="#{top.topic}"/>
<a4j:commandButton value="Delete" reRender="topic_panel"
action="#{regesterCourse.removeTopicRow}">
<a4j:actionparam value="#{row}"
assignTo="#{regesterCourse.topicIndex}"/>
</a4j:commandButton>
</rich:column>
<rich:column>
<h:outputText value="#{row}"/>
</rich:column>
</rich:dataTable>
public
System.
out.println("index is ......." + this.getTopicIndex()); //THIS STATEMENT ALWAYS RETURN 0
topicList.remove(this.getTopicIndex());
}
//end removeTopicRow()
-
-
13. Re: adding a new row
waq Jan 20, 2010 6:57 AM (in response to waq)waq wrote:
Moreover i am trying to provide a delete functionality to the user which allows the user to delete the current row. It works fine but it always delete the last row.
I beg your pardon. it always delete the first row.
Please do help me out on this issue. I've been googling since yesterday but not come up with any solution yet.
-
14. Re: adding a new row
nbelaevski Jan 20, 2010 7:02 AM (in response to waq)Have you checked if "#{regesterCourse.topicIndex}" expression has ever been updated?