You need to sign in to do that
Don't have an account?
meyerd
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
controller
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
Code:
<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:pageBlockSection>
<br/>
<apex:outputPanel>
<apex:outputPanel id="MyOutputPanelId">
<apex:inputText id="InputTextPanelId" value="{!TextFieldInPanel}"/>
</apex:outputPanel>
</apex:outputPanel>
<br/>
<apex:commandButton value="Submit Panel" rerender="MyOutputPanelId"/>
</apex:pageBlock>
</apex:form>
</apex:page>
controller
Code:
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."
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
From the docs for pageBlock the 'mode' attribute is defined as:
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.
manu
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
cheers,
manu
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.......