You need to sign in to do that
Don't have an account?
Paul Allsopp 3
Render a list of objects
Hey Peeps!
I'm having an issue that I hope someone can help me with, concerning rendering a list of objects in a VF page.
I have a controller called Ticket, which contains a generic class:
Now to display this list of comments along with other data for a Ticket, I have this markup in my VF page:
The problem is that everytime I save, I get this error:
Compilation error: Unknown property 'Ticket.Comment.body'
I'm confused because comments is a List of Comment objects, and a Comment object has a body property.
I'm fairly new to Apex, but not software development, so this is driving me nuts =)
I'm clearly missing some Java/Apex idiom here.
Thanks for any help.
Paul
I'm having an issue that I hope someone can help me with, concerning rendering a list of objects in a VF page.
I have a controller called Ticket, which contains a generic class:
public class Comment { Integer id {get; set;} String author {get; set;} String body {get; set;} String created {get; set;} }I have a list of these generic classes:
public List<Comment> comments {get { Comment [] cmt = this.fetchTicketComments(); return cmt; }set;}The method fetchTicketComments calls another method:
private List<Comment> parseTicketComments(String json_string) { Comment [] ticket_comments = new List<Comment>(); Map<String, Object> json_object = (Map<String, Object>) JSON.deserializeUntyped(json_string); List<Object> jira_ticket_comments = (List<Object>) json_object.get('comments'); while (jira_ticket_comments.size() > 0) { Comment instance_comment = new Comment(); Map<String, Object> cmt = (Map<String, Object>) jira_ticket_comments.get(0); Map<String, Object> author = (Map<String, Object>) cmt.get('author'); instance_comment.id = Integer.valueOf(cmt.get('id')); instance_comment.author = String.valueOf(author.get('displayName')); instance_comment.body = String.valueOf(cmt.get('body')); instance_comment.created = Datetime.valueOf(String.valueOf(cmt.get('created')).replace('T', ' ')).format('M/d/y hh:mm a'); ticket_comments.add(instance_comment); jira_ticket_comments.remove(0); } return ticket_comments; }
Now to display this list of comments along with other data for a Ticket, I have this markup in my VF page:
<apex:pageBlockSection rendered="{!NOT is_new}" id="comment_detail" collapsible="true"> <apex:repeat value="{!comments}" var="cmt"> <apex:outputText >Comment:</apex:outputText> <apex:inputTextarea cols="80" rows="4" value="{!cmt.body}" /> </apex:repeat> </apex:pageBlockSection>
The problem is that everytime I save, I get this error:
Compilation error: Unknown property 'Ticket.Comment.body'
I'm confused because comments is a List of Comment objects, and a Comment object has a body property.
I'm fairly new to Apex, but not software development, so this is driving me nuts =)
I'm clearly missing some Java/Apex idiom here.
Thanks for any help.
Paul
Please change your Inner class with following.
As you are try to access the Inner class property on VF, you have to specify it as Public.
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
All Answers
Hello,
Did not find any issue in above code, issue might be somewhere else.
Can you please add full code of your visualforce page and apex class here ?
Thanks & Cheers,
Jigar(pateljb90@gmail.com)
Please change your Inner class with following.
As you are try to access the Inner class property on VF, you have to specify it as Public.
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
Try to below code.
you need to write renderd here mentiond and once your Vf page code copy some other palce try to save again past same page.
<apex:pageBlock id="createList" rendered="{!AND(conCreate,NOT(redirectConPage))}">
<apex:pageMessages id="showmsg" rendered="{!conCreate}" ></apex:pageMessages>
<apex:pageBlockButtons > <apex:commandButton action="{!createRecord}" value="Create"/>
</apex:pageBlockButtons>
</apex:pageBlock>
If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
Thanks,
kae