This content has been marked as final.
Show 3 replies
-
1. Re: Urgent, please help, h:commandLink not working on first click, is it a bug?
meetoblivion Nov 30, 2008 9:22 PM (in response to valatharv)have you considered putting the param via config in your pages.xml?
-
2. Re: Urgent, please help, h:commandLink not working on first click, is it a bug?
valatharv Dec 1, 2008 12:26 AM (in response to valatharv)Thanks for replying John, I removed immediate=true and removed "int hashCode()" which was generated by JAXB, I am now able to add treatment row on single click.
However, I am not able to understand the following issue, please guide...
On clicking "Add treatment" link it adds a new row but values of previous rows are populated by default.
Example:
If h:inputText id="treatmentCompoundName" contains say "aaa" and when I click "Add treatments" link, it adds new h:inputText for treatment compound as per ui:repeat
but new h:inputText for treatment compound displays the same value as "aaa" it should be null.
------xhtml code------------
<ui:repeat value="#{quantExperimentHome.reagent1}" var="info" >
<h:inputText id="pname1" required="true" value="#{info.pname}"/>
....
<ui:repeat value="#{info.treatment}" var="itreat">
<h:inputText id="treatmentCompoundName" value="#{itreat.treatmentCompoundName}"/>
......
</ui:repeat>
<h:commandLink action="#{quantExperimentHome.addTreatmentLink}"
value="Add treatments" immediate="true" >
<f:param name="re_hashcode" value="#{info.hashCode()}"/>
</h:commandLink>
</ui:repeat>
Reagent Entity
----------------
protected List<Treatment> treatment;
@OneToMany(cascade = {CascadeType.ALL}, mappedBy="reagent")
public List<Treatment> getTreatment() {
if (treatment == null) {
treatment = new ArrayList<Treatment>();
}
return this.treatment;
}
public void setTreatment(List<Treatment> treatment) {
for(Treatment t : treatment){
t.setReagent(this);
}
this.treatment = treatment}
Treatment entity
-------------------
public class Treatment impl...{
protected Reagent reagent;
@ManyToOne(optional=false)
public Reagent getReagent() {
return reagent;
}
public void setReagent(Reagent reagent) {
this.reagent = reagent;
} -
3. Re: Urgent, please help, h:commandLink not working on first click, is it a bug?
valatharv Dec 1, 2008 12:29 AM (in response to valatharv)Sorry for the typo... h:commandLink is now
<h:commandLink action="#{quantExperimentHome.addTreatmentLink}"
value="Add treatments" >
<f:param name="re_hashcode" value="#{info.hashCode()}"/>
</h:commandLink>
and QuantExperimentHome.addTreatmentLink() is:
-----------------------------------------
public String addTreatmentLink(){
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");
for(int i=0;i<reagent1.length;i++){
if(reagent1[i].hashCode()==Integer.parseInt(reagentHashcode)){
Treatment treatment = new Treatment();
treatment.setReagent(reagent1[i]);
reagent1[i].getTreatment().add(treatment);
break;
}
}
return "";
}