+ Start a Discussion

problem re-rendering Output Panel if required field is not filled in.

I am finding the following when trying to update an ajax aware output panel.
If the required field has a value then all is good. If I blank the value of the required input field in the ui and submit the panel it does not get updated and I get no indication that anything has happened.
In the apex log I see

<apex:inputField> value '{!Opportunity.Name}' is required
***Ending Page Log for /apex/PanelTst

vf page

<apex:page controller="tstController">
<apex:form id="mainForm" >
<apex:sectionHeader title="{!Opportunity.Name}"/>

<apex:pageBlock id="mainPb">
<apex:pageBlockSection title="Opportunity Details" columns="2">
<apex:inputField value="{!Opportunity.Name}" required="true"/>

<apex:outputPanel id="MyOutputPanelId">
<apex:inputText id="InputTextPanelId" value="{!TextFieldInPanel}"/>

<apex:commandButton value="Submit Panel" rerender="MyOutputPanelId"/>


public class tstController {

private Final String oid = System.currentPageReference().getParameters().get('id');

Opportunity o;
public Opportunity getOpportunity() {
o = [select Name, CloseDate from Opportunity where Id = :oid];
return o;

Private String panelText='Y';

public String getTextFieldInPanel() { return panelText; }
public void setTextFieldInPanel(String data) { panelText = data +'X';}




You need to include a <apex:message> (for the specific component)  or <apex:messages> (for the whole page).

See the documentation:

"If a message or messages component is not included in a page, most warning and error messages are only shown in the debug log."


First rule of thumb is get your functionality working using full page updates then apply rerender/partial page updates. Not sure why you have the nested outputPanels (one id'ed and the other not - should not matter but its not adding anything). Also, if you expect error messages from inputField to be displayed you need to include the component in the rerendered region. I also noticed that you're commandButton is not tied to any action - not that this is wrong - just a bit unusual.

Finally, given what it looks like you're trying to accomplish have you considered using the standard controller on Opportunity combined with a custom extension - the standard controller takes care of a bunch of grungy bits (e.g. automatically and dynamically generates a SOQL query including any required joins based on what you reference in your page - all with out you writing any apex code!). If you find you need to add to /or modify what the standard controller gives you for free using extensions is a snap and then you only have to write the things that are special to your solution instead of gobs of getters/setters/SOQL/etc.

Message Edited by dchasman on 02-20-2008 08:30 PM
Manu ErwinManu Erwin
Have you tried adding the 'mode' attribute to your pageBlock?

From the docs for pageBlock the 'mode' attribute is defined as:
The default user mode for the pageBlock component's child elements. Possible values include "detail", in which data is displayed to the user without required field lines, and "edit", in which data is displayed to the user with required field lines. If not specified, this value defaults to "detail".
Don't know if this will achieve what you are looking for but that way you won't need to set 'Required=true' on your input fields - the mode attribute will take care of it.

Also perhaps this will take care of the auto error to the user - just guessing here.....

Hope it helps.

Not quite.  All the mode attribute does is determine your css class.  I think the doc is a bit confusing here and I will ask that it is cleared up.

The "lines" that are being referred to are the light brown separator lines that separate your field label from the actual field value, and they only show up on detail pages and not edit pages.  They do not have anything to do with requiredness.

InputFields automatically get the red requiredness bar once they are inside of a pageBlock regardless of mode.  However, if you choose to put them outside of a pageBlock, even though you do not get the requiredness bar, you will not be able to leave them empty without getting an error message (exceptions for the immediate attribute of course).  This does not explain the original issue, but I just wanted to clear that up.

Message Edited by jwetzler on 02-21-2008 01:19 PM
Manu ErwinManu Erwin
Ahhh - thanks for the clarification Jill.

Thanks for the replies. I spent a short amount of time on this today. I looked at <apex:message> but did not see an example and what I did try did not produce any messages for me to enjoy.

As for Id's and using the standard controller, I tried to put something here that would get rid of much of the code I am using and demonstrate what my underlying concern was. I have code similar to what is here but the panel(s) have opportunity line items and I am using a custom controller to add remove opportunity line items from these panels and upsert/delete when user clicks save.

I am planning on spending some more time with <apex:message> <apex:messages>

Your ideas/examples are very much appreciated.

58 pts so far manu.......
I put the message in the panel. works fine. thx