I am still figuring the way on retrieving session object after photo/file upload.
I googled on "How to retrieve session object in Java" and it shows me session.getAttribute(...). Is there any way to retrieve the session object in openxava with that concept?
My scenario is, I have set an id 155 to uId. How can I retrieve the uId 155 and display it at detail mode??
Thanks in advance.
Brian
Last edit: Brian Cheong 2017-03-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The first time user direct to the detail page, it has the url parameter value of uId=155, which the uId will set into session object. After that, all pages will parse the session object. I tried with the session that I have right now but not working like what I want. Really need some please help on this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Store the uid in a session object. Over the SaveAction of the entity and inject the session object in your class extending the SaveAction. By this way you will have access to the session object and you can do further processing like save the uid to database
Thanks
Shankar
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay thanks. Now should I change the controller of SaveAction from class="org.openxava.actions.SaveAction" to class="org.survey.actions.MySaveAction"? And I get this error: Impossible to assign values to object of class Randau because Impossible to set object properties because argument type mismatch
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I am still figuring the way on retrieving session object after photo/file upload.
I googled on "How to retrieve session object in Java" and it shows me session.getAttribute(...). Is there any way to retrieve the session object in openxava with that concept?
My scenario is, I have set an id 155 to uId. How can I retrieve the uId 155 and display it at detail mode??
Thanks in advance.
Brian
Last edit: Brian Cheong 2017-03-23
I want to do like this:
The first time user direct to the detail page, it has the url parameter value of uId=155, which the uId will set into session object. After that, all pages will parse the session object. I tried with the session that I have right now but not working like what I want. Really need some please help on this.
Store the uid in a session object. Over the SaveAction of the entity and inject the session object in your class extending the SaveAction. By this way you will have access to the session object and you can do further processing like save the uid to database
Thanks
Shankar
Hi Shankar,
Thanks for the reply.
I believe that I did store the uid in session object with this:
Do you mean that the ViewBaseAction should be replaced by SaveAction?
Please correct me if I am wrong on this. I am really headache on session part.
Thanks in advance.
Brian
I think you are using the above class to filter based on uid. Leava it as it.
Have another class extending the SaveAction
public class MySaveAction extends SaveAction {
@Inject @Named("application_uId")
private String uId;
}
Okay thanks. Now should I change the controller of SaveAction from class="org.openxava.actions.SaveAction" to class="org.survey.actions.MySaveAction"? And I get this error: Impossible to assign values to object of class Randau because Impossible to set object properties because argument type mismatch
Yes you need to add a controller for you saveaction and add it to the module in application.xml
<controller name="YourSaveAction">
<extends controller="Typical"/>
<action name="save" mode="detail" by-default="if-possible" class="org.openxava.org.action.YourSaveAction" image="images/save.gif" keystroke="Control S"/>
</controller>
<module name="YourModule">
<model name="YourModule"/>
<controller name="YourSaveAction"/>
</module>
Not clear from your message when you are getting the exception.
One other way to do this is to
@PreCreate
public void onPrecreate() throws Exception{
Thanks
Shankar
I added the controller in controller.xml and the module in application.xml. Now i got this error:
At my Randau.java.
I have the property for uId:
Did I miss something for the property?
Last edit: Brian Cheong 2017-03-27
I solved the error above by changing data type "int" to "String". But the uId is not saved into the database.
By the way, I would like to try the second method on @PreCreate. Would you mind to give more details on it?
Okay. My model class is Randau.java, isn't that it is not encouraged to use @Inject on the property?
Is this correct if I do it like this?
Please guide me as I am not good on this. Thanks alot Shankar.
Brian
Last edit: Brian Cheong 2017-03-27
The second option was just a thought not sure if it advisable to do it or not.
The first option of injectecting the session object in the SaveActionc class and set the value of uid should work.
You need to debug your code to see it the value is being set in th entity object.
Thanks
Shankar
The uId value does not set in the column. Do I need to add a line to call the MySaveAction class? Currently, I have:
Last edit: Brian Cheong 2017-03-27
You don't need to call the action class explicitly.
You have to configure an entry in the controller for the SaveAction class and use the controller in the module defintion in application.xml
Hi Shankar,
I will try to find the solution in other way.
Thanks.
Brian
Last edit: Brian Cheong 2017-03-28