1

I'm making a webscraping application so I'm not using any database just javabeans to store the data and xhtml pages to display it, now I have an arraylist objects in which every object there's data I need to display in xhtml page, but I don't know how to. I know it is posible with jsp using jstl but some days ago I heard that almost nobody uses jsp these days,... So I don't wan't to use it for this project.

javabeans

@ManagedBean(name = "login")
@SessionScoped
public class Login implements Serializable{
    private boolean isLoged=false; 
    PortalUDB portaludb;
    Estudiante estudiante; // This is the object tha has the array list

Class that contains the two arraylist of objects

public final class Estudiante{
    private Document document;
    private int uv_carrera;
    private int uv_actuales;
    private final Connection.Response loginForm;
    public List<MateriaPensum> materia_pensum = new ArrayList<>();
    public List<MateriaExpediente> materia_expediente = new ArrayList<>();

I've already achieved it using ui:repeat

<ui:repeat var="materia" value="#{login.estudiante.materia_expediente}"> <h1>#{materia.asignatura}</h1> </ui:repeat>

Just I don't know why I can use every variable in the class MateriaExpediente when they are private.

public class MateriaExpediente extends MateriaPensum{
    int anio;
    String ciclo;
    String asignatura;
    String matricula;
    float nota;
    String resultado;

Maybe because I use getter and setter methods?

2 Answers 2

1

If you're using Spring MVC or Spring Boot then you can use Thymeleaf. I am guessing you are passing the Estudiante bean to the request scope as estudiante attribute. So, in order to loop over the materia_pensum list in your html:

<p th:each="materiaPensum : ${estudiante}" th:text="${materiaPensum.name}"><p/>
Sign up to request clarification or add additional context in comments.

Comments

0

If you know Javascript/JQuery you can do it. Just send your data-list as JSON string format to client. In client side, read the list data from response and then populate the list using loop iterating the list(for that, you can fetch data by ajax request from client side).

For that, set a parent Class/Id for that xhtml area where you want to populate the data and use that as reference.
I know this is generic solution(but it will help I hope), but it would help us to help more if you try a specific way and tell us what are you facing. For further reference you can read this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.