Hi,
I need to copy value to a new item popup. I have a Registration entity which has one to many MedicalProcedure entity. I displayed medical procedures list in my registration screen. Please refer to the attachment for more information.
When I create a new medical procedure (by clicking the new button), a new Medical Procedure popup is displayed. I want customize the popup, the patient field should be automatically copied from the previous screen, so the user doesn't need to fill it in manually.
I tried creating new action to achieve tis, but got an error: "The property viewObject does not exist"
Here is my codes:
In Registration.java - this is how I display the medical procedure list.
Feb 10, 2024 4:05:48 PM org.openxava.controller.ModuleManager manageRegularException
SEVERE: The property viewObject does not exist in io.example.gp.actions.GetPatientFromRegistration
org.openxava.util.PropertiesManagerException: The property viewObject does not exist in io.ksatria.gp.actions.GetPatientFromRegistration
at org.openxava.util.PropertiesManager.getPropertyDescriptor(PropertiesManager.java:460)
at org.openxava.util.PropertiesManager.executeSetFromString(PropertiesManager.java:260)
at org.openxava.util.PropertiesManager.executeSetsFromStrings(PropertiesManager.java:364)
at org.openxava.controller.ModuleManager.setPropertyValues(ModuleManager.java:1167)
at org.openxava.controller.ModuleManager.prepareAction(ModuleManager.java:788)
at org.openxava.controller.ModuleManager.executeAction(ModuleManager.java:592)
at org.openxava.controller.ModuleManager.executeAction(ModuleManager.java:525)
at org.openxava.controller.ModuleManager.execute(ModuleManager.java:483)
at org.apache.jsp.xava.execute_jsp._jspService(execute_jsp.java:260)
hi Gregorio, I tried your suggestion, but I still got the same error:
org.openxava.util.PropertiesManagerException: The property viewObject does not exist
publicclassGetPatientFromRegistrationextendsNewAction{@Overridepublicvoidexecute()throwsException{try{super.execute();System.out.println("GetPatientFromRegistration.execute()");MedicalProcedureprocedure=(MedicalProcedure)getView().getEntity();getView().setValue("patient",procedure.getRegistration().getPatient().getId());}catch(Exceptione){System.out.println("Something went wrong!");e.printStackTrace();}}}
It doesn't execute System.out.println that I put there. The exception is thrown by OX before executing my code.
I think the problem here is that @NewAction only works from it's own module. So, when I click the new button from the Medical Procedure, it loads the view object properly then executes my code.
However, if I click new button from Registration screen, I got the error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I actually checked that same documentation about create and update views, but the issue seems to be different.
The error happens whenever I click the "New" button from another module to create a Medical Procedure, like when I do it from the Registration module. If I create the Medical Procedure directly from the Medical Procedure module itself, I don't see the error.
Just to clarify, as I mentioned earlier, this error occurs before my own code even runs, so the order of super.execute() doesn't seem to be the problem.
Would you have any other ideas about what might be causing this specific issue?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
you have:
getView().setValue("patient", procedure.getRegistration().getPatient().getId());
but patient is a reference of Entity Patient, is not a simple property like name or age.
try
getView().setValue("patient.id", procedure.getRegistration().getPatient().getId());
or
getView().getSubview("patient").setValue("id", procedure.getRegistration().getPatient().getId());
or
getView().getSubview("patient").setValueNotifying("id", procedure.getRegistration().getPatient().getId());
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Collection action must have a viewObject property. That is on that way, because you could create a reusable action to be used in several of your collection, so the action has a way to know what collection it is.
To get rid of your error just create a viewObject property in your action, thus:
@Getter@SetterStringviewObject;
But better that this, you can extends your action from CollectionElementViewBaseAction, so the viewObject is already included. And still better extends from CreateNewElementInCollectionAction, the new action for collection.
Hi,
I need to copy value to a new item popup. I have a Registration entity which has one to many MedicalProcedure entity. I displayed medical procedures list in my registration screen. Please refer to the attachment for more information.
When I create a new medical procedure (by clicking the new button), a new Medical Procedure popup is displayed. I want customize the popup, the patient field should be automatically copied from the previous screen, so the user doesn't need to fill it in manually.
I tried creating new action to achieve tis, but got an error: "The property viewObject does not exist"
Here is my codes:
In Registration.java - this is how I display the medical procedure list.
This is my controllers.xml
This is the action code:
In MedicalProcedure.java - This is the related fields declaration.
I got this error when clicking the new button:
Can somebody give me a hint to solve this issue?
Last edit: IB Afriana 2024-02-10
Hi.
change this
getView().setValue("patient", procedure.getRegistration().getPatient());
for that
getView().setValue("patient", procedure.getRegistration().getPatient().getId());
hi Gregorio, I tried your suggestion, but I still got the same error:
It doesn't execute System.out.println that I put there. The exception is thrown by OX before executing my code.
I think the problem here is that @NewAction only works from it's own module. So, when I click the new button from the Medical Procedure, it loads the view object properly then executes my code.
However, if I click new button from Registration screen, I got the error.
in the sample in document
super.execute(); it's the last line no the first.
try
public class GetPatientFromRegistration extends NewAction {
@Override
public void execute() throws Exception {
try {
}
}
Sorry my english...
Thank you for trying to help me!
I actually checked that same documentation about create and update views, but the issue seems to be different.
The error happens whenever I click the "New" button from another module to create a Medical Procedure, like when I do it from the Registration module. If I create the Medical Procedure directly from the Medical Procedure module itself, I don't see the error.
Just to clarify, as I mentioned earlier, this error occurs before my own code even runs, so the order of super.execute() doesn't seem to be the problem.
Would you have any other ideas about what might be causing this specific issue?
Hi
you have:
getView().setValue("patient", procedure.getRegistration().getPatient().getId());
but patient is a reference of Entity Patient, is not a simple property like name or age.
try
getView().setValue("patient.id", procedure.getRegistration().getPatient().getId());
or
getView().getSubview("patient").setValue("id", procedure.getRegistration().getPatient().getId());
or
getView().getSubview("patient").setValueNotifying("id", procedure.getRegistration().getPatient().getId());
Just to make it clear, the error happens before that codes are executed. Please see here, I remove my specific codes, but the error still happens.
Hi IB,
Collection action must have a viewObject property. That is on that way, because you could create a reusable action to be used in several of your collection, so the action has a way to know what collection it is.
To get rid of your error just create a viewObject property in your action, thus:
But better that this, you can extends your action from CollectionElementViewBaseAction, so the viewObject is already included. And still better extends from CreateNewElementInCollectionAction, the new action for collection.
That is, change this:
By:
Help others in this forum as I help you.
Thanks, Javier... I changed the parent class as you suggested then it works.