4

I suppose this is rather trivial but unfortunately i cannot solve this. There are two 's, which require integers as input. When user enter letters even without clicking submit button, other page functions (sorting, search) stop working. Here is full code:

<apex:page controller="MerchandiseController" tabStyle="Merchandise__c">
<apex:form >
    <h1>Merchandise List</h1>

    <apex:pageBlock title="Sorting">
        <apex:selectList value="{!selectedField}" size="1" >
            <apex:selectOption itemValue="Name" itemLabel="Merchandise Name"/>
            <apex:selectOption itemValue="Price__c" itemLabel="Price"/>
            <apex:selectOption itemValue="Quantity__c" itemLabel="Quantity"/>
            <apex:selectOption itemValue="Type__c" itemLabel="Type"/>
            <apex:selectOption itemValue="Date_Created__c" itemLabel="Date Created"/>
            <apex:selectOption itemValue="Date_Added__c" itemLabel="Date Added"/>
            <apex:selectOption itemValue="Available__c" itemLabel="Available"/>
        </apex:selectList>
        <apex:commandButton action="{!sortMethod}" value="Sort Table"/>
    </apex:pageBlock>

    <apex:pageBlock title="Search">
        <apex:inputText value="{!searchName}" label="NAME"/>
        <apex:inputText value="{!searchDateAdded}" label="DATEADDED"/>
        <apex:commandButton action="{!search}" value="Search By Name"/>
    </apex:pageBlock>

    <apex:pageBlock title="Merchandise" id="merchandiseList">
        <apex:variable value="{!0}" var="rowNum"/>
        <apex:pageBlockTable value="{!products}" var="pitem">
            <apex:column value="{!pitem.name}"/>
            <apex:column value="{!pitem.Price__c}"/>
            <apex:column value="{!pitem.Quantity__c}"/>
            <apex:column value="{!pitem.Type__c}"/>
            <apex:column value="{!pitem.Date_Created__c}"/>
            <apex:column value="{!pitem.Date_Added__c}"/>
            <apex:column value="{!pitem.Available__c}"/>
            <apex:column headerValue="Delete">
                <apex:commandLink value="Remove" action="{!removeContact}" immediate="true">
                    <apex:param name="index" value="{!rowNum}"/>
                </apex:commandlink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>

    <apex:pageBlock title="Add new">    
        <apex:pageBlockSection showHeader="false" columns="2">
            <apex:inputField value="{!product.name}"/>
            <apex:inputField value="{!product.Price__c}"/>
            <apex:inputField value="{!product.Quantity__c}"/>
            <apex:inputField value="{!product.Type__c}"/>
            <apex:inputField value="{!product.Date_Created__c}"/>
            <apex:inputField value="{!product.Date_Added__c}"/>
            <apex:inputField value="{!product.Available__c}"/>
        </apex:pageBlockSection>
        <apex:commandButton action="{!save}" value="Add item"/>
    </apex:pageBlock>

</apex:form>

And screenshot of page: capture

2 Answers 2

3

You need to put the specific region in action region tag. It is happening since visualforce is validating entire page when action occurs. Check below link,

https://www.salesforce.com/docs/developer/pages/Content/pages_compref_actionRegion.htm

1
  • Thanks, i think i understood the concept. But to be fair it is a bit messy.
    – squaremilk
    Commented May 28, 2015 at 19:34
1

Try wrapping your Price and Quantity fields in elements like so

<apex:actionRegion >
    <apex:column value="{!pitem.Price__c}"/>
</apex:actionRegion>
<apex:actionRegion >
    <apex:column value="{!pitem.Quantity__c}"/>
</apex:actionRegion>
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .