You need to sign in to do that
Don't have an account?
Force.platform
how to pass values to controller from vf with commandbutton
I have to pass quantity and price of product with commandbutton which is out of pageBlockTable.
<center> <!--------------category selection result-------------->
<apex:pageBlock rendered="{!showpageblocktable}" >
<center>
<apex:pageBlockTable value="{!selectedProWrapper}" var="p" >
<apex:column style="width:25%">
<apex:inputCheckBox value="{!p.selected}"/>
</apex:column>
<apex:column style="width:25%" headerValue="Product Name">
<apex:outputLink title="View Product Detail" onclick="return openPopUp('{!p.Eprod.id}') ">
{!p.Eprod.name}
</apex:outputLink>
</apex:column>
<apex:column headerValue=" Image">
<apex:outputText value="{!p.Eprod.Image__c}" escape="false" />
</apex:column>
<apex:column value="{!p.Eprod.Price__c}"/>
<apex:column value="{!p.Eprod.Quantity__c}"/>
<apex:Column style="width:25%">
<apex:commandLink value="Add to Bucket" action="{!AddToCartButton}" >
<apex:param name="PQuantity" value="{!p.Eprod.Quantity__c}"/>
<apex:param name="price" value="{!p.Eprod.Price__c}"/>
<apex:param name="PId" value="{!p.Eprod.Id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</center>
<!--@@@@@@@@@@ here i have to pass quantity and price @@@@@@------->
<apex:commandButton value="Add All to Bucket" action="{!AddToCartButton}" >
<apex:param name="PQuantity" value="{!p.Eprod.Quantity__c}"/>
<apex:param name="price" value="{!p.Eprod.Price__c}"/>
<apex:param name="PId" value="{!p.Eprod.Id}"/>
</apex:commandButton>
</apex:pageBlock>
</center>
</apex:form>
</apex:page>
but i am getting error:
Error: Unknown property 'Landing_Page_Controller.p' becoz this commandButton is outside of pageBlockTable and 'P' is variable of pageBlockTable. so how i can do this?
<center> <!--------------category selection result-------------->
<apex:pageBlock rendered="{!showpageblocktable}" >
<center>
<apex:pageBlockTable value="{!selectedProWrapper}" var="p" >
<apex:column style="width:25%">
<apex:inputCheckBox value="{!p.selected}"/>
</apex:column>
<apex:column style="width:25%" headerValue="Product Name">
<apex:outputLink title="View Product Detail" onclick="return openPopUp('{!p.Eprod.id}') ">
{!p.Eprod.name}
</apex:outputLink>
</apex:column>
<apex:column headerValue=" Image">
<apex:outputText value="{!p.Eprod.Image__c}" escape="false" />
</apex:column>
<apex:column value="{!p.Eprod.Price__c}"/>
<apex:column value="{!p.Eprod.Quantity__c}"/>
<apex:Column style="width:25%">
<apex:commandLink value="Add to Bucket" action="{!AddToCartButton}" >
<apex:param name="PQuantity" value="{!p.Eprod.Quantity__c}"/>
<apex:param name="price" value="{!p.Eprod.Price__c}"/>
<apex:param name="PId" value="{!p.Eprod.Id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</center>
<!--@@@@@@@@@@ here i have to pass quantity and price @@@@@@------->
<apex:commandButton value="Add All to Bucket" action="{!AddToCartButton}" >
<apex:param name="PQuantity" value="{!p.Eprod.Quantity__c}"/>
<apex:param name="price" value="{!p.Eprod.Price__c}"/>
<apex:param name="PId" value="{!p.Eprod.Id}"/>
</apex:commandButton>
</apex:pageBlock>
</center>
</apex:form>
</apex:page>
but i am getting error:
Error: Unknown property 'Landing_Page_Controller.p' becoz this commandButton is outside of pageBlockTable and 'P' is variable of pageBlockTable. so how i can do this?
just check the value - selected is true or false, wherever it is true take all those record and perform the next action.
please revert in-case of any thing more..:)
All Answers
just check the value - selected is true or false, wherever it is true take all those record and perform the next action.
please revert in-case of any thing more..:)
again i stucked with same situation,
<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.