Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Rui Lorensi

Objeto null

Recommended Posts

Boa noite galera! to aqui quebrando minha cabeça e nao consigo entender o que está errado. vamos lá: tenho um setup que tem q seguir um passo-a-passo para cadastro de um projeto, que pertence a uma organizacao, ai que ta o problema, tenho uma tela de cadastro da organizacao que funciona beleza, porem , na hora que ponho esse cadastro dentro do setup ele chama o metodo save() mas seta o objeto null. se alguem tiver alguma ideia vlw!

 

<table align="center" border="0" cellpadding="0" cellspacing="0">
           <tr><td>
                   <h:form id="val">
                       <input type='hidden' name="issubmit" value="1"/>
                       <!-- Tabs -->
                       <div id="wizard" class="swMain">
                           <ul>
                               <li><a href="#step-1">
                                       <label class="stepNumber">1</label>
                                       <span class="stepDesc">
                                           Organization Details<br />
                                           <small>Fill organization details</small>
                                       </span>
                                   </a>
                               </li>
                               <li><a href="#step-2">
                                       <label class="stepNumber">2</label>
                                       <span class="stepDesc">
                                           Project Details<br />
                                           <small>Fill your profile details</small>

                                       </span>
                                   </a>
                               </li>
                               <li><a href="#step-3">
                                       <label class="stepNumber">3</label>
                                       <span class="stepDesc">
                                           Project Context<br />
                                           <small>Fill Project Values</small>
                                       </span>
                                   </a>
                               </li>
                               <li><a href="#step-4">
                                       <label class="stepNumber">4</label>
                                       <span class="stepDesc">
                                           Overview<br />
                                           <small>Fill all details</small>
                                       </span>
                                   </a>
                               </li>
                           </ul>

                           <div id="step-1">	
                               <div >
                                   <h:outputLabel value="Organization Name" for="name" />
                                   <p:inputText value="#{organizationBean.organization.nameOrganization}" id="name" size="20"/>
                                   <h:outputLabel value="Organization Description" for="description"/>
                                   <p:inputText value="#{organizationBean.organization.descriptionOrganization}" id="description" size="20"/>

                                   <h:commandLink>save
                                       <f:ajax listener="#{organizationBean.save}" event="click" render="@all" />
                                   </h:commandLink>
                               </div><hr/>
                               <div id="oldOrg">
                                   <p:dataTable id="orgTable" var="org" value="#{organizationBean.list}"
                                                paginator="true" rows="4">
                                       <f:facet name="header">Select a ORGANIZATION for this project</f:facet>
                                       <p:column>
                                           <f:facet name="header"><h:outputText value="Org. Name"/></f:facet>
                                           <h:outputText value="#{org.nameOrganization}"/>
                                       </p:column>
                                       <p:column>
                                           <f:facet name="header"><h:outputText value="Org. Description"/></f:facet>
                                           <h:outputText value="#{org.descriptionOrganization}"/>
                                       </p:column>
                                       <p:column>
                                           <f:facet name="header">Select</f:facet>
                                           <h:column id="imgAdd">
                                               <div style=" text-align: center;">
                                                   <h:commandLink >
                                                       <h:graphicImage library="images" name="select.png" width="15" height="15"/>
                                                       <f:ajax event="click" listener="#{projectBean.addOrganization(org.idOrganization)}" render="@all"/>
                                                   </h:commandLink>
                                               </div>
                                           </h:column>
                                       </p:column>
                                   </p:dataTable>

                               </div>
                               <div style="margin: 15px 0 0 10px; font: 14px Arial; " >
                                   <fieldset style="border: 2px solid orange;"><legend>Organization selected</legend>
                                       <h:outputText id="orgName" value="#{projectBean.project.idOrganization.nameOrganization}" />
                                   </fieldset>
                               </div> 
                           </div> 

                           <div id="step-2">
                               <h2 class="StepTitle">Project Details</h2>	
                               <table cellspacing="3" cellpadding="3" align="center">
                                   <tr>
                                       <td align="center" colspan="3"> </td>
                                   </tr>        
                                   <tr>
                                       <td align="right">Name :</td>
                                       <td align="left">
                                           <h:inputText value="#{projectBean.project.nameProject}" id="nameProject" size="80">
                                               <f:ajax event="keyup" render="nameP"/>
                                           </h:inputText>
                                       </td>
                                       <td align="left"><span id="msg_firstname"></span> </td>
                                   </tr>
                                   <tr>
                                       <td align="right">Description</td>
                                       <td align="left">
                                           <h:inputText value="#{projectBean.project.descriptionProject}" id="descProject" size="80">
                                               <f:ajax event="keyup" render="descP"/>
                                           </h:inputText>
                                       </td>
                                       <td align="left"><span id="msg_lastname"></span> </td>
                                   </tr> 
                                   <tr>
                                       <td align="left">

                                       </td>
                                   </tr>                                   			
                               </table>        
                           </div>   

                           <div id="step-3">
                               <h2 class="StepTitle">Project Context</h2>
                               <div style=" height: 270px;margin: 0 0 0 100px; display: table;">
                                   <table cellspacing="3" cellpadding="3" align="center">
                                       <tr>
                                           <td align="center" colspan="3"> </td>
                                       </tr>

                                       <tr>
                                           <td >
                                               <div style="width: 450px; margin: 0 0 0 100px;">
                                                   <f:ajax event="change" listener="#{projectBean.reRenderValuesOctupos()}" render="vos">
                                                       <h:selectOneMenu value="#{projectBean.octopus}" style="height: 30px;">
                                                           <f:selectItem itemValue="nada" itemLabel="Select" />
                                                           <f:selectItems value="#{projectBean.listOctopus()}"
                                                                          var="o"
                                                                          itemValue="#{o.value}"
                                                                          itemLabel="#{o.description}">
                                                           </f:selectItems>        
                                                       </h:selectOneMenu>
                                                   </f:ajax>

                                                   <f:ajax event="change" listener="#{projectBean.addValuesOctopusToList()}" render="tableV">
                                                       <h:selectOneMenu id="vos" value="#{projectBean.valuesOctopusId}" style="height: 30px;">
                                                           <f:selectItem itemValue="" itemLabel="Select" />
                                                           <f:selectItems value="#{projectBean.listValueOctopus()}"
                                                                          var="o"
                                                                          itemValue="#{o.value}"
                                                                          itemLabel="#{o.label}" >
                                                           </f:selectItems>
                                                       </h:selectOneMenu>
                                                   </f:ajax>
                                               </div>
                                               <br/>
                                               <div style="width: 600px;  ">
                                                   <h:panelGroup id="panel" >
                                                       <h:dataTable id="tableV" value="#{projectBean.showValuesAdd()}" var="value">
                                                           <f:facet name="header" >Values Selected</f:facet>                    
                                                           <h:column>
                                                               #{value.idOctopus.varOctopus}
                                                           </h:column>
                                                           <h:column> - </h:column>
                                                           <h:column>
                                                               #{value.alternative}
                                                               <h:commandLink action="#{projectBean.removeValuesOctopusToList(value.idValuesOctopus)}" value="X Del">      
                                                                   <f:ajax render=":val:panel" />         
                                                               </h:commandLink>   

                                                           </h:column>
                                                       </h:dataTable>
                                                   </h:panelGroup>
                                               </div>
                                           </td>
                                       </tr>                                   			
                                   </table> 
                               </div>
                           </div>

                           <div id="step-4">
                               <h2 class="StepTitle">Step 4: Confirm and Save</h2>	
                               <table cellspacing="3" cellpadding="3" align="center">                                    
                                   <br/>
                                   <tr>
                                       <fieldset><legend>Organization info</legend>
                                           Name.............<strong><h:outputText id="nameO" value="#{projectBean.project.idOrganization.nameOrganization}"/><br/></strong>
                                           Description... <strong><h:outputText id="descO" value="#{projectBean.project.idOrganization.descriptionOrganization}"/></strong>
                                       </fieldset>
                                   </tr><br/>          			
                                   <tr>
                                       <fieldset><legend>Project info</legend>
                                           Name.............<strong><h:outputText id="nameP" value="#{projectBean.project.nameProject}"/></strong><br/>
                                           Description... <strong><h:outputText id="descP" value="#{projectBean.project.descriptionProject}"/></strong>
                                       </fieldset>
                                   </tr><br/>      
                                   <tr>
                                       <fieldset><legend>Project </legend>
                                           <ui:repeat value="#{projectBean.valuesOctopusList}" var="val">
                                               <strong>- <h:outputText  value="#{val.alternative}" /></strong><br/>
                                           </ui:repeat>
                                       </fieldset> 
                                   </tr>
                               </table>                 			
                           </div>

                           <h:commandLink class="buttonFinishClass" id="btnFinishId" action="#{projectBean.save()}" value="Save" style="display: none;"/>

                       </div>
                       <!-- End SmartWizard Content -->  		
                   </h:form> 

               </td></tr>
       </table> 

 

so pra ficar mais claro, a parte que ta me quebrando eh a seguinte:

<h:outputLabel value="Organization Name" for="name" />
    <p:inputText value="#{organizationBean.organization.nameOrganization}" id="name" size="20"/>
    <h:outputLabel value="Organization Description" for="description"/>
    <p:inputText value="#{organizationBean.organization.descriptionOrganization}" id="description" size="20"/>

     <h:commandLink>save
          <f:ajax listener="#{organizationBean.save}" event="click" render="@all" />
     </h:commandLink>

 

ele salva um registro null.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá, depois de muitas tentativas finalmente consegui! \0/, solução simples e funcional: coloquei um <h:form> com um id entre meu inputs e no evento execute do ajax setei execute="o".

<h:form id="o">
                                           <h:outputLabel value="Organization Name" for="name">
                                               <p:inputText value="#{organizationBean.organization.nameOrganization}" id="name" size="20"/>
                                           </h:outputLabel>
                                           <h:outputLabel value="Organization Description" for="description">
                                               <p:inputText value="#{organizationBean.organization.descriptionOrganization}" id="description" size="50"/>
                                           </h:outputLabel>

                                           <span style="margin: 0 0 0 10px;">
                                               <h:commandLink value="save">
                                                   <f:ajax listener="#{organizationBean.save()}" event="click" render="@all" execute="o" />
                                               </h:commandLink>
                                           </span>
                                       </h:form>

vlw a todos que tentaram ajudar.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.