-1

i have two table.one with apex tag another with HTML tag.in the both table i need my fields as required.eg:i want to make my input field as required.so am giving required="true" in .but while giving this the HTML tag table doesn't work.

Page :

<apex:page standardController="RFLEET_Protocol_Grid__c" extensions="RFLEET_ProtocolDynamicGrid" id="pge">

<apex:form id="frm" >

<script>
function dispalydivfun()
{
document.getElementById('dipslaydiv').style.display="block";
var radios = document.getElementsByName('md');
for (i = 0; i < radios .length; i++) {
radios[i].disabled = true;
radios[i].checked = false;
}
document.getElementById('infoDetailSecondLabel').style.display = 'none';
var Style = document.getElementById("btn").disabled=true;
document.getElementById("edName").required = true;
return false;
}
function Delete() {
hideshow();
}
</script>

<apex:actionFunction name="hideshow" action="{!Delrecords}"/>
<apex:pageblock rendered="{!showgrid}" id="pb" >
<apex:pageBlockButtons location="TOP" id="pbBtn">
<input type = "button" value="{!$Label.New_Line}" onclick="dispalydivfun()" />
<input type = "button" value="{!$Label.Delete1}" onclick="Delete()" id="btn"/> 
</apex:pageBlockButtons>
<apex:dataTable value="{!protocolgrid}" var="allcon" cellpadding="4" border="1" >
<apex:column headervalue="" > 
<apex:outputPanel id="re"> 
<input type="radio" name="md" id="targetRadio1" />
<apex:actionsupport action="{!selectcon}" event="onclick" rerender="consel" >  
<apex:param name="conid" value="{!allcon.Id}" assignTo="{!conid}"/> 
</apex:actionsupport>  </apex:outputPanel>  
</apex:column>                        
<apex:column value="{!allcon.Model__c}" headervalue="{!$Label.Model1}"  />
<apex:column value="{!allcon.Discount__c}" headervalue="{!$Label.Discount}" />
</apex:dataTable>
</apex:pageblock>

<div id="dipslaydiv" style="display:none;">
<apex:pageBlock mode="maindetail" >
<apex:pageBlockSection columns="2"> 
<apex:inputField value="{!proo.Model__c}" />
<apex:inputField value="{!proo.Discount__c}" />
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!Newlinesave}" value="{!$Label.Save3}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</div>
<!--------------slected radio values display here------------->
<div id="infoDetailSecondLabel">
<apex:pageblock id="consel" mode="maindetail" >
<apex:outputPanel id="infoDetailSecondLabel" style="float:right;" layout="none" rendered="{!showgrid}">
<apex:dataTable id="allcons" value="{!selectedContact}" var="selcon" cellspacing="5" cellpadding="8" bgcolor="WHITESMOKE">
<apex:column >
<label >{!$Label.Model1}</label>
<div class="requiredInput" style="display:inline-block"> <div class="requiredBlock"></div>
<input id="modeldiscount" value="{!selcon.Model__c}" name = "Model1" required="required"/>
</div>
</apex:column>
<apex:commandButton value="{!$Label.Save3}" action="{!Selectedval}"/>
</apex:column> 
</apex:dataTable>
</apex:outputPanel>
</apex:pageblock>
</div>
</apex:form>
</apex:page>
  • can you share your code. What have you tried. – Tushar Sharma Sep 23 '15 at 8:54
  • i have shared my code above – Mahi Sep 23 '15 at 8:58
  • apex:inputField in this field i can't find the required attribute. Where is the exact problem. – Tushar Sharma Sep 23 '15 at 9:02
  • in case i gave the required attribute in apex:input Field .the HTML tag table i.e <div id="infoDetailSecondLabel"> this table is not working – Mahi Sep 23 '15 at 9:11
  • and what thing is not working if you give required attribute. – Tushar Sharma Sep 23 '15 at 9:14
0
<div id="dipslaydiv" style="display:none;">
<apex:pageBlock mode="maindetail" >
<apex:pageBlockSection columns="2"> 
<apex:inputField value="{!proo.Model__c}" />
<apex:inputField value="{!proo.Discount__c}" />
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!Newlinesave}" value="{!$Label.Save3}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</div>

I think I have found your problem . The problem is if you mark the field required then you must fill them but as your div style display:none. I think you don't fill value in them. also as there is no Pagemessage in your page so error is also not display on the page. So when you don't fill them value it don't allow to submit your request and thats why your table is not working. Now your have two workarounds.

  1. you can use immediate attribute in command button or in any action function.
  2. Conditionally make required attribute true or false. Hope this will help you.
  • immediate attribute and required attribute used in same <div id="dipslaydiv" style="display:none;"> table – Mahi Sep 24 '15 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.