Web-app source code

spring
java
jsp
spring-mvc
d3js
Tags: #<Tag:0x00007fe7b1be0208> #<Tag:0x00007fe7b1be00c8> #<Tag:0x00007fe7b1be7f30> #<Tag:0x00007fe7b1be7df0> #<Tag:0x00007fe7b1be7cb0>

#4

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


#5

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?


#6

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


#7

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


#8

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


#9

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/


#10

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


#11

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


#13

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!


#14

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.


#15

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?


#16

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

#17

[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.


#18

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?


#19

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?


#20

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/


#21

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?


#22

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


#24

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


#25

@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