+ Start a Discussion

empty inputText value

Hi there.

I have hit a brick wall.

I have an inputText that binds to a string in my controller.

Now, when the inputText is empty, the property String in my controller is set to nothing...empty.

Every single attempt to check the value is empty with if statements, will not work.

I cannot enter my block of code is the inputText value is empty.

The use case is that the inputText is given a value by the user, a value is added to a map.

If the user removes the value from the inputText field, I want to clear the map.

This seems so simple but wont work.


Here's the relevant portion of my code:



<apex:inputText value="{!catalogueEntryOne}" id="catalogueOne"> <apex:actionSupport event="onblur" action="{!retrieveCatalogueOneProduct}" rerender="ItemTableBlock" /> </apex:inputText> .... public String catalogueEntryOne { get; set {this.catalogueEntryOne = value; System.debug('***** CATALOGUE ENTRY ONE IS: ' + catalogueEntryOne); } } ... if(catalogueEntryOne != null) { for(Shop_Direct_Product__c shopProd : productList) { if(catalogueEntryOne.equals(shopProd.Name)) { if(!tableRecMap.containsKey(shopProd.Id)) { tableRecMap.put(shopProd.Id,new ProductTableRecord(false,shopProd)); tableRecList = tableRecMap.values(); this.cacheCatalogueEntryOne = String.valueOf(catalogueEntryOne); showTable = true; } } } }else if(catalogueEntryOne.length()==0){ System.debug('***** IN ELSE!!!!! *****'); //This is NEVER printed.


Any ideas?

I have tried various combinations. I have removed the else if(catalogueEntryOne.length()==0...

In the debug log when the inputText is cleared out and has not text, I see:

***Begining Page Log for /apex/OrderPage 20090616162304.004:Class.OrderPageExtension: line 9, column 100: ***** CATALOGUE ENTRY ONE IS: 20090616162304.004:External entry point: returning from end of method public void in 1 ms


 Please help!







Best Answer chosen by Admin (Salesforce Developers) 

Sorry, spending too much time at this!

I fixed it. I had to put a check into  my if statement to become:


if(catalogueEntryOne != null && catalogueEntry != '') {