function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JNicJNic 

Putting a childs input field on a parent objects Page layout.

Hi all,

 

I'm attempting to add to the default page layout of a case object with a Visual Force page.

 

My supposrt staff have mentioned that case comments require too many clicks and page loads to get done, and would like a simple input field on the case page with a save button under it. Entering text, and then clicking save adds the comment to the case and clears the box for the next comment.

 

 

I've attempted to create this but without success. I can't figure out how to put an input field for a new child object on a visual force page.

 

My page looks like this:

 

<apex:page standardController="Case" extensions="caseLogisticsPageCtrlr" tabStyle="Case" > <apex:pageBlock> <apex:form > <apex:pageBlockTable rows="5" value="{!case.CaseComments}" var="cCom"> <apex:column> <apex:inputField value="{!cCom.CommentBody}"/> </apex:column> </apex:pageBlockTable> </apex:form> </apex:pageBlock> </apex:page>

 But as I'm sure you can tell... It just shows input fields from existing comments. 

 

My controller is this:

 

public class caseLogisticsPageCtrlr{ private final Case cse; public caseLogisticsPageCtrlr(ApexPages.StandardController stdController) { this.cse = (Case)stdController.getRecord(); } public Case getCase() { return [select id, CaseNumber, (select id, CommentBody, ParentId from CaseComments limit 5) from Case where id = :System.currentPageReference() .getParameters().get('id')]; } public String getName() { return 'caseLogisticsPageCtrlr'; } }

 

 I think I'm on the wrong track... Can anyone please help me out?

 

Thanks,

Jnic

 

 

 

Gino BassoGino Basso

Add a property to your controller extension of type CaseComments and bind to its fields:

 

public inputCaseComments {get; set;}{inputCaseComments = new CaseComments()} <apex:inputField value="{!inputCaseComments.CommentBody}" />

 

JNicJNic

Thanks Gino. I'm not sure entirely where to put that, can you explain?

 

Do I add this like so:

 

public caseLogisticsPageCtrlr(ApexPages.StandardController stdController) { this.cse = (Case)stdController.getRecord(); inputCaseComments = new CaseComment(); } public CaseComment inputCaseComments { get; set; }

 Thanks,

JNic

 

 

Gino BassoGino Basso

I imagine you've probably already tried it by now but that should work, yes.

JNicJNic

I was having some problems with eclipse on the weekend, but I jsut tried it again exactly as above and I get the following error from eclipse:

 

 "Save error: Unable to perform save on all files: an unexpected error has occurred. Please try again or check the log file for details."

 

I've tried again and get the same result.

 

 

Also... where IS the log file? :P

 

Thanks,

JNic

JNicJNic

*bump

 

Can anyone shed some light on what that means?

JMPlayer22JMPlayer22

Try looking through here...

 

Window > Show View > Force.com IDE Log Viewer

 

I'm having a similar issue...I installed the SFDC Time Off Manager and it messed up all of my triggers/Classes so that I can't save/update them anymore...getting the same message about not being able to save for unexpected reasons...

 

Also try installing the Eclipse Log Viewer as explained here:

 

http://kplab.evtek.fi:8080/wiki/Wiki.jsp?page=EclipseLogViewer

Message Edited by JMPlayer22 on 09-04-2009 10:54 AM
JNicJNic

Sorry to bump this old thread... But I wanted to share my (almost) solution.

 

I've managed to create the VF page that shows CaseComment body, and IsPublished values on the case page.

 

Here is my class:

 

public with sharing class CSEcommentAdder { public List<CaseComment> cc {get; set;} private final Case c; public CSEcommentAdder(ApexPages.StandardController myController) { c=(Case)myController.getrecord(); cc = new List<CaseComment>(); CaseComment newcc = new CaseComment(); //Set the ParentID to be the Case from which this comment is created... Duh newcc.ParentId = c.id; //Add the new line right off the bat cc.add(newcc);} //Save, and refresh Mr. Page public PageReference save() { insert cc; PageReference home = new PageReference('/apex/Caselogisticspage?id='+c.Id); home.setRedirect(true); return home; } }

 

 And here is my page:

 

<apex:page standardController="Case" extensions="CSEcommentAdder" tabStyle="Case" > <style> body { background-color:#f3f3ec;} </style> <apex:form > <apex:dataTable value="{!cc}" var="cCom" style="width: 100%; padding: 4px; border-bottom:1px solid; border-bottom-color:#e3deb8"> <apex:column style="width: 17%; padding-right:4px; text-align: right;"> <b>Comment</b> </apex:column> <apex:column style="width: 33%; align: left; padding-left:8px;"> <apex:inputField style="width: 98%; height: 100px;" value="{!cCom.CommentBody}"/> </apex:column> <apex:column style="width: 17%; padding-right:4px; text-align: right;"> <b>Make Public</b> </apex:column> <apex:column style="width: 33%; align: left; padding-left:8px;"> <apex:inputField value="{!cCom.IsPublished}"/> </apex:column> </apex:dataTable> <table width="100%" border="0"> <tr> <td align="center"> <apex:commandButton value="Add comment" action="{!save}" onclick="window.parent.location.href='/{!Case.Id}';" rerender="error" /> </td> </tr> </table> </apex:form> </apex:page>

 

 

This is functionally complete...

 

There seems to be a problem here:

 

<apex:commandButton value="Add comment" action="{!save}" onclick="window.parent.location.href='/{!Case.Id}';" rerender="error" />

 

Basically, it seems that it is refreshing the page before it adds the comment... So the user is directed to the same case, but it appears that the comment was not added.

 

The comment is, of course, added, but the user doesn't see it unless he refreshes a second time.

 

Is there a way I can take the  "onlclick" from the commandButton and put it into the PageReference in the class? I'm not sure how to do that.

 

Thanks!

JNic