I am facing issue while adding and removing text fields, looks like somehow
textfields values are stored in session.
Please help, is there anything wrong in the code...
Example Detail :
a) I am genereating textfields dynamicaaly using ui:repeat
If I add 3 textfields say with Values "AAAA", "BBBB" and "CCCC" in a row.
b) When I click on remove link against "BBBB" row, on the UI it removes
"CCCC" BUT I checked the backend methods which handles this, it looks like
it is removing correct "BBBB" in ProjectHome.removeTreatmentLink().
c) Even if "CCCC" is removed, assuming 2 rows with "AAAA", "BBBB" are left
on clicking "Add treatment link" it adds a row but displays value as "CCCC"
There is no database interaction at this point.
Log on clicking "ProjectHome.removeTreatmentLink()" link:
--------------------------------------------------------
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), compare
reagent hashcode : reagentEnitty[0]16784247, HASCODE FROM FORM UI=16784247
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), Size of T=3
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), FINAL Comp
name left = AAAA
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), compare
treatment hashcode 2 : TreatmentEntity[1]5700104, HASCODE FROM FORM
UI=5700104
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(),
TreatMent.CompName TO REMOVE =BBBB
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), FINAL Comp
name left = CCCC
12:01:51,057 INFO [STDOUT] ProjectHome.removeTreatmentLink(), outside for,
reagent[i].getTreatment() = [com.entity.Treatment_at_b4818[
treatmentCompoundName=AAAA
.......
], com.entity.Treatment_at_56fa08[
treatmentCompoundName=BBBB
.....
], com.entity.Treatment_at_127d1b4[
treatmentCompoundName=CCCC
......
]]XHTML:
------
<ui:repeat value="#{projectHome.reagent.treatment}" var="itreat">
<h:inputText value="#{itreat.treatmentCompoundName}"/>
......
</ui:repeat>
<h:commandLink action="#{projectHome.removeTreatmentLink}"
value="Remove"
onclick="if (!confirm('Are you sure you want to remove this treatment?'))
return false;">
<f:param name="re_hashcode" value="#{info.hashCode()}"/>
<f:param name="tr_hashcode" value="#{itreat.hashCode()}"/>
</h:commandLink>
ProjectHome.java
----------------
@Name("projectHome")
public class ProjectHome extends EntityHome<Project> {
.........................
.........................
public String removeTreatmentLink(){
javax.faces.context.FacesContext facesContext = (new
org.jboss.seam.faces.FacesContext()).getContext();
javax.servlet.http.HttpServletRequest
hsr=(javax.servlet.http.HttpServletRequest)facesContext.getCurrentInstance().getExternalContext().getRequest();
String reagentHashcode=hsr.getParameter("re_hashcode");
String treatmentHashcode=hsr.getParameter("tr_hashcode");
for(int i=0;i<reagent.length;i++){
System.out.println("ProjectHome.removeTreatmentLink(), compare reagent
hashcode : reagentEnitty["+i+"]"+reagent[i].hashCode()+", HASCODE FROM FORM
UI="+reagentHashcode);
if(reagent[i].hashCode()==Integer.parseInt(reagentHashcode)){
int sz=reagent[i].getTreatment().size();
Treatment t[] = new Treatment[reagent[i].getTreatment().size()];
for(int k=0;k<t.length;k++){
t[k]=reagent[i].getTreatment().get(k);
}
System.out.println("ProjectHome.removeTreatmentLink(), Size of
T="+t.length);
Treatment t1[] = new Treatment[t.length-1];
ArrayList<Treatment> al= new ArrayList<Treatment>();
for(int j=0;j<t.length;j++){
if(t[j].hashCode()==Integer.parseInt(treatmentHashcode)){
System.out.println("ProjectHome.removeTreatmentLink(), compare
treatment hashcode 2 : TreatmentEntity["+j+"]"+t[j].hashCode()+", HASCODE
FROM FORM UI="+treatmentHashcode);
System.out.println("ProjectHome.removeTreatmentLink(),
TreatMent.CompName TO REMOVE ="+t[j].getTreatmentCompoundName());
}else{
System.out.println("ProjectHome.removeTreatmentLink(), FINAL Comp
name left = "+t[j].getTreatmentCompoundName());
al.add(t[j]);
}
}
System.out.println("ProjectHome.removeTreatmentLink(), outside for,
reagent[i].getTreatment() = "+reagent[i].getTreatment());
reagent[i].getTreatment().clear();
reagent[i].setTreatment(al);
break;
}
}
return "";
}
--
View this message in context: http://www.nabble.com/preserve-exactly-the-same-datamodel-during-the-apply-request-values-phase-tp20774909p20774909.html
Sent from the jsf-extensions dev mailing list archive at Nabble.com.