Menu

Load Image/Cancel changed URL

2017-02-23
2017-02-24
  • Brian Cheong

    Brian Cheong - 2017-02-23

    Hi all,

    As the title above, the page url changed after I clicked "Load Image" or "Cancel". After my research, I found out ImageEditor.jsp and Ids.java are the files that determine the url. Is there any way to ensure it navigates to the parent url instead of altering the codes in both files? Hereby, I have uploaded images indicating the change of url.

    Thanks.

    Brian

     

    Last edit: Brian Cheong 2017-02-23
  • Shankar

    Shankar - 2017-02-23

    As I understand you directly wnat to go to the page where you clicked "Add". when load image or cancel is clicked

    The above scenario is a two step process.

    1. When you click add the screen to load the image isdisplayed where you create photo entity.

    2. When Save is clicked in image loaded screenn the link table btween the parent entity and photo entity is created

    Directly going to the parent after Clicking Load Image will not create the link between parent entity and Photo Entity

    This the default behaviour of OX for parent child relation

    Thanks

    Shankar

     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    Hi Shankar,

    Can it be done if I add eg. "LocId=1885" at the url of the loaded child page?

    Thanks.

    Brian

     

    Last edit: Brian Cheong 2017-02-24
  • Shankar

    Shankar - 2017-02-24

    Hi Brian

    I am not sure what you want to acheive and what use case you are solving. But as caution changes to OX code should be avoided since you may not be aware of all the use cases where code will be used and inadvertantly break some functionality.

    Thanks
    Shankar

     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    Hi Shankar,

    Actually, I want the url of the child page exactly the same as the parent page. For instance, the parent page before pressing "Load Image" button is localhost:8080/Bckp/m/Activity?LocId=18, thus, after I pressed the button, the child page must be the same without altering/removing the parameter. Do you think that it can be done? Or it is fixed by OX default behavior?

    Thanks.

    Brian

     

    Last edit: Brian Cheong 2017-02-24
  • Shankar

    Shankar - 2017-02-24

    You can store the locId which comes as parameter in the parentURL and use the same in other places. Not sure why you want to retain the locId parameter in the child page also

     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    I need to retain the parameter so that I can set the parameter value at detail mode if user add another activity data. Since the child page removed the parameter, the LocId value won't be set anymore unless reopen the form. Do you know which java class does the funtion for storing the displayed url?

    Thanks

    Brian

     

    Last edit: Brian Cheong 2017-02-24
  • Shankar

    Shankar - 2017-02-24

    Use the session object to the store the locId and inject it wherever you want to use it.

     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    I can't use session object because current user will display the last visited user's data. I'll try with @Stereotype("PHOTO_GALLERY") and get back here. Thanks alot.

     
  • Shankar

    Shankar - 2017-02-24

    I am not sure what you mean by session object cannot be used becuase current user will display last visited data.

    You know your code best !!!

     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    From my previous post: once I logged in user1 (LocId=11), his data is successfully seperated from user2 (LocId = 12). However, once I logged in user2/user3/user4 again, user1's data is always being loaded. In order to filter the data, I have to restart the tomcat server for each time I login different user.

     
  • Shankar

    Shankar - 2017-02-24

    code from previous post

    @Inject @Named("application_locId")
    private String locId;

    @Inject
    private Tab tab;
    
    public void execute() throws Exception {
        if (Is.empty(locId)) locId = getRequest().getParameter("locId");
        if (!Is.empty(locId)) tab.setBaseCondition("${locId}='" + locId + "'");
        else tab.setBaseCondition("${locId}='ERROR'");
     }
    
     Brain you keep the Injection of session object
    
     change the line
    
     if (Is.empty(locId)) locId = getRequest().getParameter("locId");
    
     to
     locId = getRequest().getParameter("locId");
    
     basically your getParameter each time even if locId is present.
    
     So you should be able to use the session object
    
    Thanks
    
    Shankar
    
     
  • Brian Cheong

    Brian Cheong - 2017-02-24

    Great, it works! Thanks alot.

     
  • Brian Cheong

    Brian Cheong - 2017-02-28

    Hi all,

    Due to I find no way to retain the url of the page after I pressed "Load Image" button for @Stereotype("PHOTO"), I am trying to use @Stereotype("IMAGES_GALLERY") and here comes the error: "Table 'survey.images' doesn't exist. I have no idea why I get this error because I am using MySQL to store the image. Please help.

    Thanks.

    Brian

     
  • Javier Paniza

    Javier Paniza - 2017-03-02

    Hi Brian:

    Have you a table called 'survey.images' in your database. If not, you have to create it.


    Help others in this forum as I help you.

     
  • Brian Cheong

    Brian Cheong - 2017-03-03

    Hi Javier,

    Thanks for the solution. The URL changed after I loaded the image. Is there any way to retain the URL? For instance, I want it to be the same as the previous URL before load image: http://localhost:8080/Survey/m/Image?UId=115, instead of http://localhost:8080/Survey/m/Image?application=Survey&module=Image. Please help me on how to make it inline as I don't want user to enter a NULL Uid into the database.

    Thanks in advance.

    Brian

     

    Last edit: Brian Cheong 2017-03-03
  • Javier Paniza

    Javier Paniza - 2017-03-06

    Hi Brian:

    Is there any way to retain the URL?

    No. You should store the data in a session object the first time you get the URL.


    Help others in this forum as I help you.

     
  • Brian Cheong

    Brian Cheong - 2017-03-07

    Hi Javier,

    1. The image uploaded for the first time did store in the database with its session but since the url changed after load image, the session ends? I need to press ALT+LEFT ARROW buttons to go back to the previous url with parameter values.

    2. According to the code at http://stackoverflow.com/questions/42362709/openxava-filter-data-based-on-logged-user, isn't that the session is set? If not, what should I do to store my data in session object?

    3. The parameter value is needed to display at the url because I will set their value in a property (see attached figure). So, that's how the value is stored in my database. Since the URL changed, the value will not set in the property.

    Please correct me if I am wrong.

    Thanks

    Brian

     

    Last edit: Brian Cheong 2017-03-07
  • Javier Paniza

    Javier Paniza - 2017-03-09

    Hi Brian,

    The image uploaded for the first time did store in the database with its session but since the url changed after load image, the session ends?

    No, the session does not end.

    what should I do to store my data in session object?

    Just an @Inject in an attribute of your action, is enough. Take a look at:
    http://openxava.wikispaces.com/controllers_en

    Note specially the sections about session objects and dependency injection.


    Help others in this forum as I help you.

     

Log in to post a comment.