vendredi 27 février 2015

tomahawk selectBooleanCheckbox and java script

Need some assistance with an issuing I am having with a t:selectBooleanCheck and a javascript. I have several checkboxes which become visible on certain conditions which all call a javascript method to disable and enable buttons on the page.


I have move one of the checkboxes to its own column to make a better display. Since I move the checkbox, the javascript method doesn't recognize it as part of the set checkboxes. I believe this to be the functionality that goes with JSF.


myPage.jspx



function checkBoxSelectedCountIgnoreId(collection, ignoreId) {
count = 0;
for (i = 0; i < collection.length; i++) {
elem = collection[i];
if (elem == null) {
break;
}else if (elem.checked && elem.id == ignoreId) {
//dont count ignoreId in checkbox checked count
}else if (elem.checked) {
count++;
}
}
return count;
}

function manageCommandButtons(checkbox) {
parentTD = checkbox.parentNode;
parentTR = parentTD.parentNode;
parentTBODY = parentTR.parentNode;
checkBoxCollection = parentTBODY.getElementsByTagName("input");


var printBtn = "printBtn";
var printIpadBtn = "printIpadBtn";
var emailBtn = "emailBtn";
var formId = checkbox.form.name;

var checkBoxCount = checkBoxSelectedCountIgnoreId(checkBoxCollection,"summaryFrm:shuttleIncluded");
/*
* disabling email button for now, always.
*/
if (checkBoxCount == 1) {
disableObject(formId, printBtn, false);
disableObject(formId, printIpadBtn, false);
disableObject(formId, emailBtn, false);
} else {
if (checkBoxCount > 1) {
disableObject(formId, printBtn, true);
disableObject(formId, printIpadBtn, true);
disableObject(formId, emailBtn, false);
} else {
disableObject(formId, printBtn, true);
disableObject(formId, printIpadBtn, true);
disableObject(formId, emailBtn, true);
}
}
}

<t:div rendered="#{quote.containerTariffQuote}" style="width: 100%">
<t:div style="float: left; width: 50%">
<t:panelGrid columns="2" >
<t:selectBooleanCheckbox id="formContainerEstimateOrderForService"
value="#{quote.forms.formContainerEstimateOrderForService}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerEstimateOrderForService"
value="#{labels['l.pages.forms.forms.containerEstimateOrderForService']}&#160;#{labels['l.pages.forms.forms.requiresOrderNumber']}" />

<t:selectBooleanCheckbox id="formContainerOnePageEstimate"
value="#{quote.forms.formContainerOnePageEstimate}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerOnePageEstimate" value="#{labels['l.pages.forms.forms.onePageEstimate']}" />

<t:selectBooleanCheckbox id="formSurveyContainer"
value="#{quote.forms.formSurvey}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formSurveyContainer" value="#{labels['l.pages.forms.forms.survey']}" />

<t:selectBooleanCheckbox id="formCityPointeReferralAuthContainer"
value="#{quote.forms.formCityPointeReferralAuth}"
onclick="manageCommandButtons(this)"/>
<h:outputLabel for="formCityPointeReferralAuthContainer"
value="#{labels['l.pages.forms.forms.cityPointeReferralAuth']}"/>

<t:selectBooleanCheckbox id="formWorkOrderContainer"
value="#{quote.forms.formWorkOrder}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formWorkOrderContainer" value="#{labels['l.pages.forms.forms.workOrder']}" />
</t:panelGrid>
</t:div>
<t:div style="float: right; width: 50%">
<t:panelGrid columns="2">
<t:selectBooleanCheckbox id="formContainerConfidentialWorksheet"
value="#{quote.forms.formContainerConfidentialWorksheet}"
onclick="manageCommandButtons(this)" />
<h:outputLabel for="formContainerConfidentialWorksheet"
value="#{labels['l.pages.forms.forms.confidentialWorksheet']}" />
</t:panelGrid>
</t:div>
</t:div>


I would like all the checkboxes to be recognized in checkboxCollection.


I am using tomahawk 1.1.9, richfaces 3.3, and myfaces 1.2.





Aucun commentaire:

Enregistrer un commentaire