0

this is the visualforce page

<apex:page controller="Search">
<apex:form >
  <apex:pageBlock >
    <apex:pageBlockSection >
            <label>Tag</label>
             <input type="text" name='tag'/><br/>
            <label>Location</label>
             <input type="text" name='location' /><br/>         
    </apex:pageBlockSection>
    <apex:pageBlockButtons >
        <apex:commandButton value="Search" action="{!find}"/>
    </apex:pageBlockButtons>
   </apex:pageBlock>
 </apex:form>
</apex:page>

And the controller class

public with sharing class Search 
{ 
    public PageReference find() {        
        return null;
    }
}

So i want to send tag and location into the find method and print them on visualforce page .I've no idea how can i do this.Can anybody help me

Thanks in advance

2
<apex:page controller="Search">
<apex:form >
  <apex:pageBlock >
    <apex:pageBlockSection >
            <label>Tag</label>
             <apex:inputText value="{!strTag}"/><br/>
            <label>Location</label>
               <apex:inputText value="{!strlocation}"/><br/>     
    </apex:pageBlockSection>
    <apex:pageBlockButtons >
        <apex:commandButton value="Search" action="{!find}"/>
    </apex:pageBlockButtons>
   </apex:pageBlock>
 </apex:form>
</apex:page>

public with sharing class Search 
{ 
    public String strTag {get;set;}
    public String strlocation {get;set;}
    public PageReference find() { 

        system.debug('========strTag======='+strTag);
        system.debug('========strlocation======='+strlocation);      
        return null;
    }
}
  • Worked !. if i want those outputs on the page back.how i do it – moin khan Dec 18 '15 at 10:24
  • what do you mean on page back ? – Ratan Paul Dec 18 '15 at 10:27
  • On the same page where the form is – moin khan Dec 18 '15 at 10:30
  • <apex:form > Salesforce use there standard component and generate html form tag on page – Ratan Paul Dec 18 '15 at 10:32
  • Actually the thing is that on your example you just print them on log but if i want them to display on VisualForce page then how to do that – moin khan Dec 18 '15 at 10:34
2

You should:

  • Define variables for each input in the controller OR
  • If using an object (inputs are the field of the object) - define a new instance of the object in your controller
  • Use visualforce tags apex:inputText of apex:inputField
  • Use a apex:commandButton to be able to submit your inputs and send it back to the controller

Very helpful for you will be:

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.