Passing data from one view to another

Asked

Viewed 43 times

1

I am trying to implement the following function, when the user clicks the edit button, it would send to the page "create" only populated. but when I try to do so, he sends but with nothing.

in my xhtml is like this

<p:commandButton value="Deletar" icon="fa fa-fw fa-remove"
                type="submmit" action="#{proprietarioBean.editar(proprietario)}"
                update="form" styleClass="ui-icon ui-icon-pencil" >
   <f:setPropertyActionListener target="#{proprietarioBean.proprietario}" value="#{proprietario}"/>
</p:commandButton>

In the method editar I’m just giving a setProprietario and a redirect.

public String editar(Proprietario proprietario) {
       setProprietario(proprietario);
       setTelefones(telefoneService.buscar(getProprietario()));
       return "inserirProprietario.xhtml";
}

Up to the line of setProprietario the object proprietario is not null, soon it should appear on the other side of the screen.

  • Put the method code editar, please

  • 1

    If the Ean proprietary bean does not have a larger scope than Viewscoped this approach will not work. Please inform the scope of the propretarioBean

  • this viewScoped, which recommends?

  • @Igorventurelli ok

  • 1

    @Danilo recommends that you maintain the Viewscoped scope but change the way you pass objects. Instead of passing the whole object. send an identifier as parameter in the URL, and then in the other screen recover from the database the object from the reference. However if you don’t want to change the approach now, just change the scope to Sessionscoped and its implementation should work ;)

  • 1

    @Bonifacio thanks for the answer, I will do passing only the ID to recover the object on the other side.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.