You need to sign in to do that
Don't have an account?

passing parameter from vf to controller
i have to pass parametet with commandbutton which is outside of table.
this is my vf:
<apex:form styleClass="myFormStyle " >
<center>
<!----------------pageBlock--------------------------------------->
<apex:pageBlock title="My Bucket" >
<apex:pageMessages id="msg"> </apex:pageMessages>
<!-------------first section-display table and take quantity from user----------------->
<apex:pageblockSection >
<apex:pageBlockTable value="{!itemInBucket}" var="i">
<apex:column value="{!i.Product_Name__c}" />
<apex:column value="{!i.price__c}" />
<apex:column value="{!i.Quantity__c}" headerValue="Available Quantity"/ >
<apex:column headerValue="Required Quantity" >
<apex:commandButton value="+" action="{!incrementCounter}" reRender="bucket"/>
<apex:inputText value="{!count}" style="width: 25px !important;" styleClass="qty " id="bucket"/>
<apex:commandButton value="-" action="{!decrementCounter}" reRender="bucket"/>
</apex:column>
<apex:Column >
<apex:commandLink value="Place Order" action="{!placeOrderForSinglePro}" >
<apex:param name="Pname" value="{!i.Product_Name__c}"/>
<apex:param name="price" value="{!i.price__c}" />
<apex:param name="quantity" value="{!i.Quantity__c}" />
</apex:commandLink>
</apex:column>
<apex:Column >
<apex:commandLink value="cancel" action="{!cancelOrder}" rendered="true" >
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
<!---------------------second section- take address and name from user--------------->
<apex:pageBlockSection >
<apex:inputText value="{!n}" label="Name" />
<apex:inputTextarea title="Address" value="{!a}" label="Address"/>
</apex:pageBlockSection>
<!---------------commandButton is in pageBlock------------------------------->
<apex:commandButton value="Place Order for All Products" action="{!placeOrderForAllPro}"/>
</apex:pageBlock>
</center>
<apex:commandLink value="View Order" action="{!openOrderPage}"/>
<apex:commandLink value="Previous Page" style="float:right;" action="{!redirect}"/>
</apex:form>
</apex:page>
here i am taking quantity name and address from user and storing all that into Order__C object. now my inputFileds are in diffrent pageBlockSection and my command button is in pageBlock. so how can i insert that to Order__c when i click on commandButton.
this is my vf:
<apex:form styleClass="myFormStyle " >
<center>
<!----------------pageBlock--------------------------------------->
<apex:pageBlock title="My Bucket" >
<apex:pageMessages id="msg"> </apex:pageMessages>
<!-------------first section-display table and take quantity from user----------------->
<apex:pageblockSection >
<apex:pageBlockTable value="{!itemInBucket}" var="i">
<apex:column value="{!i.Product_Name__c}" />
<apex:column value="{!i.price__c}" />
<apex:column value="{!i.Quantity__c}" headerValue="Available Quantity"/ >
<apex:column headerValue="Required Quantity" >
<apex:commandButton value="+" action="{!incrementCounter}" reRender="bucket"/>
<apex:inputText value="{!count}" style="width: 25px !important;" styleClass="qty " id="bucket"/>
<apex:commandButton value="-" action="{!decrementCounter}" reRender="bucket"/>
</apex:column>
<apex:Column >
<apex:commandLink value="Place Order" action="{!placeOrderForSinglePro}" >
<apex:param name="Pname" value="{!i.Product_Name__c}"/>
<apex:param name="price" value="{!i.price__c}" />
<apex:param name="quantity" value="{!i.Quantity__c}" />
</apex:commandLink>
</apex:column>
<apex:Column >
<apex:commandLink value="cancel" action="{!cancelOrder}" rendered="true" >
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
<!---------------------second section- take address and name from user--------------->
<apex:pageBlockSection >
<apex:inputText value="{!n}" label="Name" />
<apex:inputTextarea title="Address" value="{!a}" label="Address"/>
</apex:pageBlockSection>
<!---------------commandButton is in pageBlock------------------------------->
<apex:commandButton value="Place Order for All Products" action="{!placeOrderForAllPro}"/>
</apex:pageBlock>
</center>
<apex:commandLink value="View Order" action="{!openOrderPage}"/>
<apex:commandLink value="Previous Page" style="float:right;" action="{!redirect}"/>
</apex:form>
</apex:page>
here i am taking quantity name and address from user and storing all that into Order__C object. now my inputFileds are in diffrent pageBlockSection and my command button is in pageBlock. so how can i insert that to Order__c when i click on commandButton.
Give it a try with <apex:param> to send value to controller from VF page with the help of command link
You can use apex:actionFunction to pass the variable and call the function that is written in a controller.
<apex:commandButton value="Place Order for All Products" action="{!placeOrderForAllPro}"/>
In above you can call the apex:actionFunction using onClick on the CommandButton.
Go through the below link to know more.
Regards
Suraj
i went through above link. but i have to pass parameter with apex:actionFunction.
Use <apex:param> to pass value using <apex:actionFunction>.
Example -
Visualforce Page-
Controller -
In the Above example, I am using <apex:param> to send the value to the controller.
Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards
Suraj