I think I came up with a solution.
Since I use CODI, I can use the ConversationGroup annotation. I created the emtpy AddressConversation interface and then added it to all the beans support, which should show the address/addressEdit.xhtml , as well as the bean support for the addressEdit .
I also use CODI view configuration, so my action methods return ViewConfig derived class objects.
@Named @ConversationScoped @ConversationGroup(AddressConversation.class) public class AddressView implements Serializable { private Class<? extends Views> fromView; private Address editAddress; private Address returnAddress;
So, in my calling view (PrimeFaces commandLink)
<p:commandLink value="#{enquiryView.addressLinkText}" action="#{enquiryView.editAddress()}" immediate="true"/>
and in a backup bean EnquiryView I can @Inject create an instance of AddressView in the correct conversation group, and then set the address and return properties when the action method is called.
@Named @ConversationScoped @ConversationGroup(AddressConversation.class) public class EnquiryView implements Serializable { @Inject @ConversationGroup(AddressConversation.class) private AddressView addrView; public Class<? extends Views> editAddress() { addrView.setAddress(editEnq.getAddress()); addrView.setFromView(Views.Enquiry.EnquiryEdit.class); return Views.Address.AddressEdit.class; } }
I can also watch navigation in the EnquiryView and update the query object when the address has been saved as an address edit.
protected void onViewConfigNav(@Observes PreViewConfigNavigateEvent navigateEvent) { if (navigateEvent.getFromView() == Views.Address.AddressEdit.class && navigateEvent.getToView() == Views.Enquiry.EnquiryEdit.class) { onEditAddressReturn(); } } private void onEditAddressReturn() { if (addrView.getReturnAddress() != null) {
source share