How to make textfield readonly if value in shuttle is not selected - oracle-adf

I have a textfield and would like to not make it read only if a value is selected from a shuttle (many options can be picked). I am using Jheadstart to create the page, but an adf solution works just as well as I can just insert that change into ta template.Normally I would use a binding and select the input value of of another field, but I am not sure what to select with the shuttle as a shuttle can have many selections.

To get the values from the shuttlebox inside a bean:
BindingContainer myBC = this.getBindings();
JUCtrlListBinding listBinding = (JUCtrlListBinding)myBC.get("ViewObject1"); //viewObject that populates the shuttflebox
Object str[] = listBinding.getSelectedValues();
if(str.length>0)
isTextBoxDisabled=false;
else
isTextBoxDisabled=true;
Then bind the Disabled property of the inputtext to myBean.isTextBoxDisabled
This would need a page submit in order to activate, so I'm guessing that's not what you are after.
If you want it to automatically update the values as their are moved around in the shuttle, you will have to use the ValueChangeListener property of the shuttle, in which to get the size of the selections.
public void selectValueChangeListener(ValueChangeEvent valueChangeEvent) {
ArrayList list = new ArrayList(Arrays.asList(valueChangeEvent.getNewValue()));
if(list.isEmpty())
isTextBoxDisabled=true;
else
isTextBoxDisabled=false;
//refresh the inputText component
AdfFacesContext.getCurrentInstance().addPartialTarget(myInputText);
}
Bear in mind the ValueChangeListener will only get processed via their bean method when the page is submitted. If you want the change processed when changing the value of the shuttle, set autoSubmit = true.

Related

Push value from input to object array and update tab names labels- Angular

I have a reactive form and I am using Material Angular, with a tab group and the tab names comes from an array, I need to add the possibility of changing those tabs names for new ones. If a write a new title in the input I need to update the name of the tab label.
I’m getting the value from the input, but I can’t figure it out how to send it to the names of the tabs:
app.component.ts
this.newTitleArm = selection.formdata.titleTextArms;
console.log(this.newTitleArm);
STACKBLITZ
SCREENSHOT
Can you have a look at this Stackblits
Note that I have modified the submit method and have added
if(this.form.get('titleArms').value === 'changeArm'){
this.tabs[this.selected.value].name = this.form.get('titleTextArms').value;
}
Here I'm assigning the titleTextArms control value to selected tab name. You can get selected tab by this.tabs[this.selected.value]
Also added the if condition to check selection of radio button.
UPDATE:
since you have used tab names to create the text in the parent component.
In the submit method
need to do the tab name update before emitting the updateDataEvent.
submit(): void {
if (this.form.get('titleArms').value === 'changeArm') {
if (this.form.get('titleTextArms').value !== '') {
this.tabs[this.selected.value].name =
this.form.get('titleTextArms').value;
}
}
this.updateDataEvent.emit({
formdata: this.form.getRawValue(),
tabs: this.tabs,
});
}
The problem is that you are not updating the respective tab name anywhere, neither in your submit, nor in your updateData.
You submit the value, but you are not updating the tabs.
For example, in your submit method add this hard-coded update and then press the Save button:
this.tabs[0].name = "test";
Because now you updated the first tab's name, you should see the change.

why the combo box displays the objects?

I have a combobox which I would like to populate with some info. Below is the code:
cmbSelectProject.Items.Clear();
cmbSelectProject.ValueMember = "Sid";
cmbSelectProject.DisplayMember = "Name";
cmbSelectProject.DataSource = new BindingSource(ApiCaller.LstProjects, null);
So, there is a class Project with the existing properties "Sid" and "Name". ApiCaller.LstProjects call returns a list of Projects. So I expect the "Name" to de displayed and "Sid" is used as value.. Instead I see the bunch of Project objects displayed in the dropdown.
What am I doing wrong in here? Thanks for the suggestions.
Try This sequence.
Set DataSource property.
Set ValueMamber and DisplayMember.
Refresh Combo. using Refresh() method.

How to get know if a checkbox has been selected in a dynamic UI in codenameone

I have a container with dynamic UI components including checkboxes. How can I know the selection status of a particular component?
Using isSelected() doesn't work as it is always false because it seems to pick the last checkbox in the list which returns false since it is unselected.
bool_isMemberSelected = cb_member.isSelected(); //returns false.
I am able to get the checkbox at a particular index in the parent component but once I have it there is no isSelected option on it. So I use a dirty way by tokenizing the string representing the component to get to the selected status. There must be a better way.
System.out.println("Checkbox Data "+cnt_tablerow[Integer.parseInt(lbl_memberno.getName())].getComponentAt(0)); //Checkbox Data: CheckBox[x=0 y=0 width=63 height=152 name=524, text = , gap = 2, selected = true]
String str_chkbox = StringUtil.tokenize(StringUtil.tokenize(cnt_tablerow[Integer.parseInt(lbl_memberno.getName())].getComponentAt(0), ']').get(0), '[').get(1);
String str_status = StringUtil.tokenize(StringUtil.tokenize(str_chkbox, ',').get(3), '=').get(1).trim();
if(str_status == "true"){}
You could generate and set a name for each component when generating your dynamic UI. With a name you can use the ComponentSelector API or a simple for to get the Checkbox you want and then use the isSelected method.
If you want to keep your actual selection logic with the index, you can simply check the instance of your component and cast it to a CheckBox, that would also do the trick.

how to add a empty string as default in the drop down where dropdown is a directive

In my AngularJS project, I am having a dropdown field as a directive and the values are coming from the backend.The user can also leave the field without selecting the dropdown(optional field) but the problem is, there is no empty field from the backend. So I need to add an empty field into the dropdown as default.
Since there is no option in the directive got struck in this issue.Googled a lot but didnt get any solutions yet.Kindly provide some suggestion.
Note:Client machine,cant post the code.
If there is no value set for the ng-model that the dropdown is bound to, Angular will provide a blank option by default that can be left in place (ignored) by the user and will result in your final value being whatever you set that ng-model to in the first place. If you need an actual empty string for the value, initialize it to that.
If you need to enable the user to select an empty value once they have already selected a value, you will need to add an empty value to the object that the dropdown is bound to. Add the empty value like this:
myPromise.then(function(data){
$scope.ddInfo = data;
$scope.ddInfo.unshift({id:'0000',text:'Not Applicable'});
});

Angularjs refreshing select values after adding a new item

I am adding a new item to the available select options in a modal box and updating the server. When I close the modal, i want to see the new added option in the select box and actually selecting it without refreshing the entire page, so just select box needs to be updated. Is this possible?
Page;
<select ng-model="scores" ng-options="score for score in options.scores" />
so on the model box, i add a new value to options.scores
Try wrapping your ng-model in a container object, to prevent any scope hierarchy issues.
ng-model="state.scores"
Where you defined state like:
$scope.state = {};
// then whenever you want to set your scores.
$scope.state.scores = ...
You should read up on angular's scope hierarchy. http://jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html

Resources