Web-app source code

About your second question, to add a link to the page, just add your html in the jsp.

If the code you want to add uses data from the model, you need to add an entry in the model Object in the controller method. This is a classical map, key/value.

Once in the model, the data can be simply accessed by using ${myKeyInTheModelMap} in the jsp. That will then interpreted before being rendered by the server.

Regarding the kind of Java object you associate to the key in the map, you can for instance :

  • access to the any attribute of the object : ${myKeyInTheModelMap.myClassAttribute}. The class must simply define a method called “getMyClassAttribute”
  • iterate over a collection with a <c:forEach tag,
  • and so many other stuffs.

Enjoy and thanks for your interest
Feel free to ask other questions

Regards

Koj

3 Likes

Ok thanks a lot! Let’s say that i want to add another graph to the html identical for example to the score graph but i want this to be computed with a different formula computed by java code that i will write. How complex would something like that be? Or what if i would like to create a new view containing some graphs which would display some of the data from the database?

2 Likes

Hi,

It depends on what kind of graphics you want to create.
We currently use the d3.js library to build our graphics.

To do so, we create in the jsp a table with the data, that is then used by some javascript code to collect dara, build the graphics and then hide the original data by css.

You may use another way, we can discuss about it, if you have any idea.

Regards

Jerome

1 Like

And what about creating an extra view? Of course a controller is essential and a new .jsp i suppose. What else?

Furthermore, how could i make changes to the source code using an IDE and test the results on my browser?

1 Like

hi @nivak91,

For Linux users, with docker and maven:

git clone https://github.com/Asqatasun/Asqatasun.git
cd Asqatasun
git checkout develop
 
# make changes to the source code using an IDE 
# (...)

# builds with maven, builds docker image and runs a new docker contenair
docker/compile_and_build_docker_image.sh -l -s ${PWD} -d docker/single-container-SNAPSHOT-local

In your browser, go to
http://127.0.0.1:8085/asqatasun/

Thanks a lot @fabrice! I hadn’t installed asqatasun with docker. Should i reinstall using docker?

1 Like

You can have a standard Asqatasun
on http://127.0.0.1:8080/asqatasun/

and another for testing your changes
on http://127.0.0.1:8085/asqatasun/
with Docker

Ok @fabrice i tried to do it this way but the compile takes too much time and i want to test very often the changes i make. Do i need to compile everytime or a refresh on the browser is enough?
I have made some changes such as putting a link in home.jsp:

<div class="span16">
   <h1><fmt:message key="home.h1"/></h1>
   <a href="<c:url value="mypage.htm"/>"My Page</a>
</div>

but after running :

docker/compile_and_build_docker_image.sh -l -s ${PWD} -d docker/single-container-SNAPSHOT-local 

the link i added is absent in http://127.0.0.1:8085/asqatasun/home.html although it exists on home.jsp.
Also i added a simple view named mypage.jsp and this controller:

@Controller
public class MyPageController{         
    @RequestMapping(value = TgolKeyStore.MY_PAGE, method = RequestMethod.GET)
    //@Secured({TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY})
    public String MyPage(HttpServletRequest request,
            HttpServletResponse response,
            Model model){
        return TgolKeyStore.MY_PAGE_VIEW_NAME;
    }
}

Of course i added: public static final String MY_PAGE = "/mypage";
and : public static final String MY_PAGE_VIEW_NAME = "My-page" in TgolKeyStore.java and configured view.properties by adding:

My-page.(class)=org.springframework.web.servlet.view.JstlView
My-page.url=/WEB-INF/view/MyPage.jsp

But when i go to http://127.0.0.1:8085/asqatasun/mypage it says i am not allowed to access this resource.

Any ideas would be very helpful. Thanks!

1 Like

Problems solved! Instead of typing http://127.0.0.1:8085/asqatasun/mypage i should type http://127.0.0.1:8085/asqatasun/mypage.html (i don’t know why) and for compiling i added mvn clean install -Dmaven.test.skip=true to the script.

1 Like

My new question is whether each time i compile and run a new container a new database is created? I already have an asqatasun database from the installation without docker with the default credentials, so if it is created how could it be the same?

1 Like

for compile_and_build_docker_image.sh script
you can use –skip-build option

first compile Asqatasun

cd Asqatasun
mvn clean install

after, compile only webapp

cd Asqatasun/web-app
mvn clean install

and run a new docker contenair with –skip-build option

cd Asqatasun
docker/compile_and_build_docker_image.sh --skip-build -l -s ${PWD} -d docker/single-container-SNAPSHOT-local
1 Like

[quote=“nivak91, post:15, topic:259, full:true”]
My new question is whether each time i compile and run a new container a new database is created? [/quote]
when you run a new Docker container, a new database is created inside this new container.

1 Like

Hi again. I’m trying to find the methods which when an audit is launched, write the results to the database. Could you help me?

Also another question that i have is where are the parameters of draw function of score-min.js set? I would like too use this script in order to make more than one score graphs in a page. Is that possible by changing those parameters?

And how can i have access to this database? Port 3306 is already used by asqatasun running on http://127.0.0.1:8080/asqatasun/

Hello again! If i make changes to the database how are the native SQL queries affected? For example if i add a new table or add to an existing table should i change them?

1 Like

hi @nivak91,

I think the next 3 questions are for @koj or @mfaure. :gift:
But can you describe what you want to do (not the how but what and why). :bar_chart:

You can also tell us what changes you want to make
on the database : (CREATE TABLE (…) and ALTER TABLE (…) :file_cabinet:

1. Modify the database structure

2. Find methods that record the result of an audit to the DB

3. score-min.js

A post was split to a new topic: Steps to create new view with newly computed data (for WQAM - Web Quantitative Accessibility Metric)

@nivak91, added new options to the script compile_and_build_docker_image.sh

 -b | --build-only-dir <directory> Build only webapp and <directory> (relative to SOURCE_DIR)
 -w | --build-only-webapp          Build only webapp (relies on previous build)
      --skip-build-test            Skip unit tests
2 Likes