Cannot render Object with Thymeleaf: Property or field cannot be found on object of type 'org.parse4j.ParseObject' - maybe not public?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cannot render Object with Thymeleaf: Property or field cannot be found on object of type 'org.parse4j.ParseObject' - maybe not public?

santafebound
I've been following this guide http://www.thymeleaf.org/doc/articles/springmvcaccessdata.html to learn how to render data models into a Springboot application with Thymeleaf. I have a function that retrieves a list of objects from my Parse-Server and renders them as model attributes:

    @RequestMapping(value = "/requests", method = RequestMethod.GET)
    public String findRequestsByCurrentUser(Model model) {
   
        ParseUser currentUser = ParseUser.getCurrentUser();
        log.info(String.valueOf(currentUser.getObjectId()));
   
        findRequestsByCurrentUser(model, currentUser);
   
        return "requests";
    }
   
   
    private void findRequestsByCurrentUser(Model model, ParseUser currentUser) {
        ParseQuery<ParseObject> requestsQuery = ParseQuery.getQuery(ParseConstantsUtil.CLASS_REQUEST);
        requestsQuery.whereContains(ParseConstantsUtil.REQUEST_AUTHOR, currentUser.getObjectId());
        try {
            List<ParseObject> requestsArrayList = requestsQuery.find();
            model.addAttribute("requests", requestsArrayList);
            log.info(String.valueOf(requestsArrayList));
            log.info(String.valueOf(requestsArrayList.size()));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

Here is a debug of the model that I send to my view:



I am able to render the objects because I can include static text instead of its attributes and it will loop 15 times (the number of objects retrieved in the query). But whenever I type ``request.requestText`` or ``request.requestStatus`` I get an error:



Exception:

    Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'requestText' cannot be found on object of type 'org.parse4j.ParseObject' - maybe not public?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:207) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:96) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:48) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:358) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:267) ~[spring-expression-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
    at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:263) ~[thymeleaf-spring5-3.0.3.M1.jar:3.0.3.M1]
    ... 116 common frames omitted

Why are the ParseObject attributes not accessible to Thymeleaf?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot render Object with Thymeleaf: Property or field cannot be found on object of type 'org.parse4j.ParseObject' - maybe not public?

Metroids
They are available... but you are trying to access a nonexistent property.  According to your picture, there is no property on request called "requestStatus."  There is however a property called data, that has requestStatus as a key.  So maybe this would work (depending on the type of object requestStatus is)?

<td th:switch="${request.data['requestStatus']}">

Loading...