Issue with checked checkbox in Liferay/Alloy UI - liferay

I have a form which has the checkbox. I am saving the check box value as true/false based on selecting of the check box. If I open the form in a edit mode, I am able to get the value from DB as true or false. Now I get the value as true I need to show the checked checkbox in my form OR If the value is false then I need to show the unchecked checkbox. please give me some suggestions.
<%= user.isadmin() %> // here I am getting either true or false
Based on above value I need to check or uncheck the check box,
<aui:input type="checkbox" name="isadmin" label="Is Admin"></aui:input>
If I use,
<aui:input type="checkbox" name="isadmin" label="Is Admin" checked="<%= user.isadmin()>"></aui:input>
Though user.isadmin() value is true, I am getting an error.

Use following way for checking checkbox based on the value of user.isadmin()
<% String checked = user.isadmin() ? "checked" : "" %>
<aui:input type="checkbox" name="isadmin" label="Is Admin" <%=checked %>></aui:input>

Related

VBA how to fill in search bar with ID?

Web page has the following HTML without an ID - how do I set the value of the form?
<input name="loanxFindBorrower" onkeypress="if((window.event&&window.event.keyCode==13) ||
(event.which&&event.which==13 )){ findByBorrowerAction()}" type="text" size="25" value="">
I've tried
IE.Document.getElementByTagName("loanxFindBorrower").Value = "New Value"
Aswell as
IE.Document.getElementByTagName("loanxFindBorrower").Focus
IE.Document.getElementByTagName("loanxFindBorrower").Value = "NewValue"
Any help would be much appreciated
You should use getElementsByName() to get the element. It returns a collection, you'll need to specify the index to get the element you want.
For example, if it's the first element with name "loanxFindBorrower" in the page, the index is 0:
IE.Document.getElementsByName("loanxFindBorrower")(0).Value = "New Value"

Angular changing a select value to null based on other select change

i am trying to add a popup form using an ng-template which have multiple selects .on ngOnInit() i add all the values as null
some of these selects are shown based on the previous select value using ngif
the problem is that when i change the value the second select go away but its value still the same this is my code :
<div *ngIf="cosForm.value.customer=='617e7d83c68272eba7c36c13'">
<div class="form-group text-right">
<label class="col-form-label" for="service">customer</label>
<select ng-model="selectedItem" class="form-control" placeholder="customer" autocomplete="customer"
formControlName="customer" required
[ngClass]="{ 'is-invalid': submitted && f.customer.errors, 'is-valid': f.customer.touched && !f.customer.errors }">
<option *ngFor="let customer of myCustomers" value="{{customer._id}}">{{customer.name}}</option>
</select>
<div *ngIf="submitted && f['customer'].errors" class="invalid-feedback">
<div *ngIf="f['customer'].errors.required">customer is required</div>
</div>
</div>
i want when i change the first select value the second ng select value set to null
i tried to use
<select onChange="cosForm.value.customer=null"> </select>
on the first select but i didnt get any result
i wanted to use :<div *ngIf="cosForm.value.customer=='!617e7d83c68272eba7c36c13'">
but i couldn't figure out how to affect the value
BTW: even if i change the first select, without changing the second ,i think the second select value is automatically changed because my submit button change to invalid and it became valid only when i fill the second select
If you are trying to invalidate another select based on one select then you can listen to changes in the first select tag with this
form.controls.customer.valueChanges.subscribe(()=>{
// Set the value of the second select to null here
form.controls.secondSelect.reset()
})

How to click on Web check box using Excel VBA?

How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.

Liferay Portal 6.2 - checkbox into search container

I created a search container table that contains a column checkbox type, i.e.
<liferay-ui:search-container-column-text
name="territoriale"
orderable="<%= true %>"
>
<input type="checkbox" id="territoriale" checked="<%= cmt.getTerritoriale() == 1 %>" />
</liferay-ui:search-container-column-text>
This table is declared inside a jsp included using liferay-util:include, but can also be refreshed in the next steps by click on search button.
What happen is that when the table appears for the first time, I see that column just with text (value is "1"), when I click search button that runs the ajax call, the resource action return the correct checkbox in column.
Any ideas?
Below some screen shot
Thanks
Column after page load
Column after click on search button
This works fine on 6.2 CE ga5:
<liferay-ui:search-container-column-text
name="checkbox"
orderable="<%= true %>"
>
<% String checked = (Math.random() < 0.5) ? "checked" : ""; %>
<input type="checkbox" <%= checked %>/>
</liferay-ui:search-container-column-text>
So the root cause of your issue should be somewhere else. You may output cmt.getTerritoriale() into html to check its content.
I think, that checked="<%= cmt.getTerritoriale() == 1 %>" is not correct,
you may use checked or nothing.
See here about using checked attribute.
You can also use rowchecker as was mentioned in the comments of Pankajkumar Kathiriya.

Kohana 3 form select validation

Hay all,
I am trying to validate a select in kohana 3.0 and I am using the necessary rules. However the validation does no "kick in" when the user does not make a selection.
<select id="discipline" name="discipline" >
<option value="0"> -- Select One -- </option>
<option value="-2">Information Technology and Engineering</option>
<option value="4">Business and Training Seminars</option>
</select>
That was my select, now i have applied these rules to the post array before i check for validation errors.
$post = Validate::factory($_POST)
->rule('discipline', 'not_empty')
->rule('discipline', 'numeric');
When I submit the form without making a selection, the form submits and the rules should stop it.
Any ideas ?
Your still putting a value for the first one, as 0. Leave the value as value="". 0 is numeric and considered not empty.
Replace 0 with blank string
Add ->rule('discipline', 'in_array', array(array(-2, 4))); to check that selected discipline is within valid collection.
string empty first option
<select name="fruit" required>
<option value="">select fruit</option>
<option value="banana">banana</option>
</select>
then some css may help
form:invalid button[type="submit"], form:invalid input[type="submit"] {
opacity: 0.5;
cursor: default;
}

Resources