2 Replies Latest reply on Nov 25, 2008 2:30 AM by Val Sw

    Pls suggest on how to store field values temporarily so that it can be used on different page

    Val Sw Expert
      How to store field values temporarily so that it can be used on different page.

      I have entity Reagent(parent) and Treatment(child), one reagent can have multiple treatments.

      As per requirement both entity fields should be on single page... where I need to allow user to add multiple treatments.

      I am facing issues while Creating, I was trying to provide Add button where user can fill the fields and those fields should be reflected on output-text fields on main.xhtml after closing the TreatmentEdit.xhtml...

      Please suggest what should be the best approach I should go for.

      <ui:repeat value="#{projectHome.reagent}" var="info" >
           <h:inputText id="pname1" required="true" value="#{info.pname}"/>
                <ui:repeat value="#{info.treatment}" var="itreat">
                     <h:outputText value="itreat.treatmentCompoundName"/>
                     <h:outputText value="itreat.treatmentCompoundNameDesc"/>

                          <s:button title="Add more treatments to this reagent"
                               value="Add treatment"
        • 1. Re: Pls suggest on how to store field values temporarily so that it can be used on different page
          Mikael Andersson Master

          You'll need to give us some more information

          For example which scope is your backing bean projectHome in? It it is in session scope then you are fine, you just need to do some work in setting the object you want to add more treatments to in your backing bean.
          Otherwise you might want to consider using a long running conversation, or add the some value to the request (via request parameters).


          • 2. Re: Pls suggest on how to store field values temporarily so that it can be used on different page
            Val Sw Expert
            Thanks for replying Micke...

            Hierarchy of entities are Project > QuantExperiment > Reagent > Treatment.

            I need to add multiple treatments to reagent row, as per ui:reapeat tag above.

            My ui:repat works fine, like if I add "addTreatmentLink" method in project home and from above ui use "h:commandLink action="#{projectHome.addTreatmentLink}" it adds a treatment row for reagent. But as per requirement, we should take user to other page where user can fill treatment fields and on closing the other page treatment fields should be reflected in main page.

            Please suggest, if we can make use of this code or any other way around....

            <h:commandLink action="#{projectHome.addTreatmentLink}" 
            value="Add treatments" immediate="true">
            <f:param name="re_hashcode" value="#{info.hashCode()}"/>
            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<reagent.length;i++){
                                reagent[i].getTreatment().add(new Treatment());
                 return "";     

            package com.session;

            public class ProjectHome extends EntityHome<Project> {

                 public void setProjectHjid(Long id) {

                 public Long getProjectHjid() {
                      return (Long) getId();

                 protected Project createInstance() {
                      Project project = new Project();
                      return project;

                 public void wire() {

                 public boolean isWired() {
                      return true;

                 public Project getDefinedInstance() {
                      return isIdDefined() ? getInstance() : null;

                 public List<QuantExperiment> getQuantExperiment() {
                      return getInstance() == null ? null : new ArrayList<QuantExperiment>(
                ReagentHome reagentHome=new ReagentHome();
                TreatmentHome treatmentHome=new TreatmentHome();          
                 private Reagent[] reagent=new Reagent[]{new Reagent()};
                 private Reagent initializeReagent(Reagent re){
                      List<Treatment> t=re.getTreatment();                    
                           t.add(new Treatment());               
                      return re;
                 public ProjectHome(){
                      for(int i=0;i<reagent.length;i++){
                 public Reagent[] getReagent() {
                      return reagent;
                 public void setReagent(Reagent[] reagent) {
                      this.reagent = reagent;