Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: How to specify pathname for image in XHTML file  (Read 12004 times)
Candy M.
Posts: 139


« on: January 08, 2018, 04:23:07 pm »

We are using a custom sign on to the GBC, using this code on Github:
https://github.com/FourjsGenero/ex_simplesso

So we are having some success.
We have place the external file in it's own group defined in as.xcf:
Code
  1. <GROUP Id="mttestwebapp">$(res.path.mttestpath.test_webapp)</GROUP>
  2.  
Code
  1. <GROUP Id="mttestwebsvc">$(res.path.mttestpath.test_wsapp)</GROUP>
  2.  

So the external configuration file for the app resides in /users/mtdev/test_webapp and the
external configuration file for the webservice resides in /users/mtdev/test_wsapp.

The XHTML files for the forms reside in /users/mtdev/mt.res.

So the in the application code for the web service (HTTPHelper.4gl), I tweaked the path for the form:
Code
  1. FUNCTION SendWelcomePage(req, login_url)
  2.  DEFINE  req         com.HttpServiceRequest
  3.  DEFINE  login_url   STRING
  4.  DEFINE  htmlContent STRING
  5.  DEFINE  htmlDom     xml.DomDocument
  6.  DEFINE  node        xml.DomNode
  7.  DEFINE  list        xml.DomNodeList
  8.  
  9.  LET htmlDom = xml.DomDocument.Create()
  10.  #Load the HTML as xml document
  11.  CALL htmlDom.load ("mt.res/MTSSOLogin.xhtml")
  12.  #CALL htmlDom.load ("../res/SSOLogin.xhtml")
  13.  
  14.  

It finds the form and displays it in my browser.   
But it does not find the image I have in the HTML code:
Code
  1. <img src="mt.res/web_mtstart.png" ></img>
  2.  

I have tried changing that to all sorts of paths.   This is what it shows in the Chrome developer's console:

GET http://192.168.21.4/gas/ua/r/mttestwebapp/mt.res/web_mtstart.png 404 (Not Found)

Here's the app configuration file:
Code
  1. <APPLICATION Parent="defaultgwc"
  2.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.    xsi:noNamespaceSchemaLocation="https://4js.com/ns/gas/3.10/cfextwa.xsd"
  4. >
  5.        <EXECUTION>
  6.                <PATH>$(res.path.mttestpath.bin)</PATH>
  7.                <DVM>/bin/bash</DVM>
  8.                <MODULE>mt_launch_gbc_test.sh</MODULE>
  9.                <DELEGATE service="mttestwebsvc/MTSSOService"/>
  10.        </EXECUTION>
  11.  <AUTO_LOGOUT>
  12.    <TIMEOUT>6000</TIMEOUT>
  13.    <PROMPT Timeout="9000" Type="DELEGATE">mttestwebsvc/MTSSOService</PROMPT>
  14.  </AUTO_LOGOUT>
  15. </APPLICATION>
  16.  

Here is the web service configuration file:
Code
  1. <APPLICATION Parent="ws.default"
  2.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.    xsi:noNamespaceSchemaLocation="https://4js.com/ns/gas/3.10/cfextws.xsd"
  4. >
  5.  <EXECUTION>
  6.    <ENVIRONMENT_VARIABLE Id="FGLWSDEBUG">9</ENVIRONMENT_VARIABLE>
  7.    <ENVIRONMENT_VARIABLE Id="FGLSQLDEBUG">9</ENVIRONMENT_VARIABLE>
  8.    <ENVIRONMENT_VARIABLE Id="MTPATH">/users/mtdev</ENVIRONMENT_VARIABLE>
  9.    <ENVIRONMENT_VARIABLE Id="DBNAME">mtdev</ENVIRONMENT_VARIABLE>
  10.    <PATH>$(res.path.mttestpath.bin)</PATH>
  11.    <DVM>/bin/bash</DVM>
  12.    <MODULE>MTSSOService.sh</MODULE>
  13.  </EXECUTION>
  14.  

How do I go about figuring out where to place that image?   

Thank you for any insight.

Gas 3.10.08 and Genero 3.10.09.   Using fastcgidispatch through Apache on centos 7

Candy
Candy M.
Posts: 139


« Reply #1 on: January 09, 2018, 12:42:18 am »

So I looked at this some more today and got it working.   I moved my image to

/users/gas/3.10.08/web/pic

And in my XHTML file, the path for the image is:

Code
  1. <img src="../../../pic/web_mtstart.png" ></img>
  2.  

So, this isn't very clear to me.   I'm really puzzled why it would not work unless I had ../../../
Unless it was relative to where the XHTML docs were (/users/mtdev/mt.res)
What is the path in as.xcf that specifies where web documents are?
I want to separate our code from the GAS directory.   Do I need to add a path where I want my web docs to reside?

Thank you for any help.

Candy
Frank G.
Four Js
Posts: 48


« Reply #2 on: January 09, 2018, 10:03:30 am »

Hi,

 Actually, when you are behind a GAS, for performance issue it is recommended to let the web server serve the images. So a good solution is to have them in the GAS pic directory for instance. The GAS is by default configured to serve the images in that directory. As you did. But as your HTML form is served via a web service accessible on a URL of the form http://host:port/GAS/group/app/myservice, the images in that form are relative to the URL to fetch the HTML form. So to have the images correctly served by the GAS, you must add the ../../../pic in the HTML form to finally have the browser fetching the images in http://host:port/gas/group/app/myservice/../../../pic/image.jpg, or in short : http://host:port/gas/pic/image.jpg .

If you want the images to be located else where, you have to configure the web server to access them properly and then of course have the correct path in the HTML form returned by the web service, or otherwise you have to write a web service to server your images. But not necessary as this is something the GAS does well.

Regards,
Frank
Candy M.
Posts: 139


« Reply #3 on: January 09, 2018, 02:33:49 pm »

Thank you Frank.   That is clearer.   So 4js recommends putting logo images, etc in the GAS pic directory?

Candy
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines