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
Johnny #5Johnny #5 

How to get I the value from the visualforce inputField?

I have two things: a visualforce page and an extension class to go w/ it...

 

In the visualforce page, I have this line to allow user to select a parent case....

 

<apex:inputField id="ParentId_Prop" value="{!Case.ParentId}" />

 

The question is how do I access the value that user inputs here, so I can do some validation check.

 

Any help is appreciated...  Happy New Year!

Andy BoettcherAndy Boettcher

How are you defining "Case" in your extension?

 

-Andy

yvk431yvk431

from the looks of the syntax i guess you are using standard controller. In order to get the input value you just need to access the standard controller instance in your extension constructor.

 

 

public class myControllerExtension{

private final Case cs;
public
myControllerExtension(ApexPages.StandardController stdController) { this.cs = (Case)stdController.getRecord(); }

public string getvalues()
{
string str = cs.parentId ;
system.debug('***Case ParentId***'+cs.parentId);
return str;
}

}

 

 

Johnny #5Johnny #5

Andy:

 

Thanks for the quick respone.

 

Maybe if I share my what I try to accomplish it will help a little: I am trying to verify the parentId that the user specified doesn't any one of the record he/she selected.

 

So, at the page header, I have

 

<apex:page apiVersion="23" standardController="Case" id="MassiveCaseUpdatePage" recordSetvar="Cases" extensions="MassiveCaseUpdate" >

 

somewhere in the body of the visualforce page, I have 

 

<apex:inputField id="ParentId_Prop" value="{!ParentId}"/>

 

In my extension class,

 

I now have...

 

private String parentCaseNumber;

 

public SObject getParentId(){
return Case.parentId;
// return parentCaseNumber;
}

public void setParentId(String CaseNumber){
parentCaseNumber = CaseNumber;
}

 

The problem is that I don't know what return type the getParentId method should be.  Am I heading the right track?  Sorry, I am c# developer try to be an apex developer.  :)

yvk431yvk431

Generally an inputField can only be used with SObject fields. Meaning it should refer to a concreate instance of an Object.

 


Andy BoettcherAndy Boettcher

My apologies - it's a bit tough to understand exactly what you are trying to do.  There are a number of different things that could be a silver bullet for you, but could you post your full code so we can understand the context of how you're trying to code this page?

 

-Andy