1

I am using apex:selectlist to set values from VF page to controller. Here is the VF page screenshot - enter image description here

objectname is an apex property that stores Object name and limitset holds the maximum number of records to query.

The thing is, the code works fine when we select both the values in VF page. However, the action method - "processRequest" is not invoked if either of the objectname or limitset is not selected in the VF page. I am not able to understand why something weird is happening. I wanted to display a pageMessage in case either of the values is not selected.

Any help would be appreciated. Thanks.

1
  • Is it possible to show your processRequest method from controller?
    – misha_m
    Apr 7, 2015 at 10:06

2 Answers 2

0

Have you checked the debug log to really be sure that your action isn't being run?

I think it could be that everything is working, but you don't have the messages on the page (or you're missing the rerender).

To get the message you want to appear, you'll need to include an <apex:pageMessages id="messages"/> on your page and then include it in the rerender attribute for your command button.

5
  • pageMessages can be handled later. The first thing is to call the method. The action gets called when both the selectlist values are chosen. This doesnt work when any one of them is not selected. Yes I have also checked the debug log properly. Apr 7, 2015 at 10:08
  • Can you post the actual code? The whole of the processRequest method, using a the code formatting tags, rather than as an image?
    – Aidan
    Apr 7, 2015 at 10:44
  • @Aiden - Since I was not selecting either Object or limit, the VF was passing null to the controller method. However, due to some reason, Salesforce was not generating debug log, may be because the method is making an HTTP callout. As soon as i put a null check before making the callout, it started generating debug log Apr 7, 2015 at 10:45
  • Good, glad it's solved. I was going to say debug logs can go missing when the controller methods go wrong in certain ways. But that's so vague, I didn't think it would help. I was just trying to remember where I'd seen that behaviour before!
    – Aidan
    Apr 7, 2015 at 10:55
  • Yes that's pretty weird. Debug logs should always be generated. Sometimes developer really get confused. Apr 7, 2015 at 10:57
0

Debug logs can sometimes behave in a weird way. In my case, the debug log wasn't generating despite the fact that the method was getting called from the VF page. The only thing missing in my method was a null check. My method is making an HTTP callout using Object name and a Limit value. Whenever these values were null, it was anyways making the callout but was getting error from the target end point. As a result, the debug log wasn't generating (unexpected though !!). May be, this is happening because the method is making an HTTP callout. Hence I conclude to take all the precautions in the method before making any http callout, so that salesforce doesn't behave weird and generate all the logs successfully.

3
  • Sorry guys it was a silly mistake. Since I was not selecting either Object or limit, the VF was passing null into the controller. However, due to some reason, Salesforce was not generating debug log, may be because the method is making an HTTP callout. As soon as i put a null check before making the callout, it started generating debug log. Apr 7, 2015 at 10:43
  • Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. Apr 7, 2015 at 10:52
  • @mas0r - Sorry about that. I will take care of that. I will remove that thing from answer section and post the actual answer. Apr 7, 2015 at 10:54

You must log in to answer this question.

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