ADF Cascading Lov Search and Select popup customization - oracle-adf

I have built a cascading LOV with Group and division fields (Combo box with list of values). When I select a value for Group and click on Search and Select dialog for Division field, the SearchAndSelect popup has both Group and Division fields as search criteria(as defined in my view criteria).
Now, is there a way to populate the Group value in the popup criteria, I know the where clause uses the already entered Group value but I want to display it to the user in the SearchAndSelect popup search region.

There is no declarative way of pre setting search field values in lov popup. Although it can be done by using a custom launchPopupListener for lov component. To know more about how to use lov popup listeners refer to Building Custom Lovs
Create a launchPopupListener method for your dependent lov.
<af:inputComboboxListOfValues id="inpClv2"
popupTitle="Search and Select: #{bindings.StateProvince.hints.label}"
value="#{bindings.StateProvince.inputValue}"
label="#{bindings.StateProvince.hints.label}"
model="#{bindings.StateProvince.listOfValuesModel}"
required="#{bindings.StateProvince.hints.mandatory}"
columns="#{bindings.StateProvince.hints.displayWidth}"
shortDesc="#{bindings.StateProvince.hints.tooltip}"
partialTriggers="inpClv1"
launchPopupListener="#{backingBeanScope.lovBean.stateLaunchPopupListener}">
</af:inputComboboxListOfValues>
In launchPopupListener set the value of search criteria attribute with the value from first lov.
public void stateLaunchPopupListener(LaunchPopupEvent launchPopupEvent)
{
UIXInputPopup lovComponent = (UIXInputPopup)launchPopupEvent.getSource();
ListOfValuesModel model = lovComponent.getModel();
if (model != null)
{
QueryDescriptor queryDesc = model.getQueryDescriptor();
/** Code to pre populate a Search and Select field**/
ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
List<Criterion> criterionList = conCrit.getCriterionList();
for (Criterion criterion: criterionList)
{
AttributeDescriptor attrDesc = ((AttributeCriterion) criterion).getAttribute();
if (attrDesc.getName().equalsIgnoreCase("CountryId"))
{
List values = ((AttributeCriterion) criterion).getValues();
values.set(0, "US"); //use the value from first lov
}
}
}
}

Related

How do I get a LazyComboBox to select an item from another page in Vaadin?

I am using Vaadin 7.5.5 and Viritin 1.35. I have implemented a LazyComboBox that is backed by a Spring Data JPA service call and repository.
My basic setup for the LazyComboBox is:
initList(
Site.class,
new FilterablePagingProvider() {
#Override
public List findEntities(int index, String name) {
return sitesService.findByName(name);
}
},
new FilterableCountProvider() {
#Override
public int size(String name) {
return sitesService.countByName(name);
}
},
PAGE_SIZE
);
This works great when I am typing in the combo box.
If I pick an item from the first page (page 0) I can then leave the combo box, come back to it, and click the drop down arrow again and the previously selected item is still selected.
However, if I choose an item from any page other than 0, then clicking the drop down arrow causes the selected item to become null and the user has to find the original item again.
I can post the details of the service and repository if needed but it isn't anything more complicated than a select * from table where name like '%' + name + '%'.
How do I keep the selected value in the combo box no matter what page was chosen?
Thank you.
I think you should call setNullSelectionAllowed(false); on this combo box.
Also, a solution to keep selected value after navigation can be to store it in a session value, then you'll be able to retreive it wherever you are. See Session wiki page

Adf Search panel with checkbox

I added a checkbox to my search panel, the search is working initially in the sense if I select the check box and add a query string I am getting the expected result in the table. If I click on the column header and try to sort it my table gets reset with the filtered out result.
I figured that the executeQuery of the ViewObject is getting called each time I am clicking on sort. I added code to set the value of the viewCriteria attributes here but tat is also not working. My executeQuery method included below;
public void executeQuery() {
ViewCriteria vc = this.getViewCriteria("RegionMasterCriteria");
if (null != vc.getCurrentRow()) {
if (null != vc.getCurrentRow().getAttribute("Active") &&
vc.getCurrentRow().getAttribute("Active").equals("true")) {
setActiveVariable("Y");
} else {
setActiveVariable("N");
}
}
super.executeQuery();
}
vc.getCurrentRow() is null when I am trying to perform search. The Criteria is has Auto query set to true so that when the page loads the table has default search data. But then why will vc.getCurrentRow() become null..
Can you try using executeQueryForCollection(java.lang.Object qc, java.lang.Object[] params, int noUserParams)
instead of executeQuery()?
You will be able to find your "Active" view criteria attribute in method argument:
java.lang.Object[] params
just keep in mind 'params' is a matrix (array of arrays).

Editing Redmine calendar in dashboard

In Redmine's calendar, I would like to show all Tasks/Issues on which a currently logged in person in the account is a Member, Task Creator, Assignee, Reporter, or Watcher.
Now, from the following two arrays of helper.rb, I have created another array which merges issues_only and tasks_only. Then I wish to call that array in view part.
def issues_only
issues_all = issuesreportedbyme_items
issues_all.push *issueswatched_items
issues_all.push *issuesassignedtome_items
all = issues_all.reject{|v| v.tracker_id == 4}
rest = all.reject {|k| k.status_id == 5 }
rest.inject([]) { |result,h| result << h unless result.include?(h); result }
end
def tasks_only
tasks_all = issuesreportedbyme_items
tasks_all.push *issueswatched_items
tasks_all.push *issuesassignedtome_items
all = tasks_all.reject{|v|v.tracker_id == 5}
rest = all.reject {|k| k.status_id == 5 }
rest.inject([]) { |result,h| result << h unless result.include?(h); result }
end
Now, my question is what to include in view part in order to show the required calendar.
As you can see on this image the Calendar tab has filter options same as all other lists in Redmine. First you click on the filter switch icon (the little triangle on the image) and then you can add your filters to a report, list, gantt chart etc by selecting the filters from the filter selection combo box.
Your main problem will be that this filters don't have any logical operator feature. All the filters you select will be connected with the 'AND' operator so you can't define a list, gantt or report which corresponds to your 'OR' operator.
To get all the activities of all members of a specific project you only have to select the project and then unselect the "is : open" filter on the project calendar and click on "Apply Settings".
PS : This image is taken from our customized Redmine installation which has the Easyredmine plugin but the basics of filters are the same with Redmine.
Edit:
A way achieving your 'OR' requirement would be just selecting the filters which don't belong to your requirements and applying those filters. This way you would exclude those specific criteria that you want to apply the 'OR' statement to.
Don't forget to select the appropriate status filter in your filters. (Status is open/close/any/is not/is)

Salesforce: Picklist(multiple) with dynamic value

I have add custom field to Account with picklist(multiple) in Salesforce. But the values of picklist should be dynamically generated from other object. If not, is it possible to push values in picklist from native app(which is written in ruby)?
I dont think the standard controller supports dynamically adding the possible picklist (select list) values.
What you could do is add a text field instead of a picklist and create a custom page with visualforce. Use the standard controller with an extension for your code.
Create a new custom object for holding picklist values for a field (could be reused for other fields). Populate it with the possible picklist values.
In the page controller, load the values for that field.
In visualforce, display a picklist for the custom field and load the values from the controller.
Add an extra input field for manual insertion if desired.
On save, insert the value of the picklist (or input box) into the custom field.
A more detailed guide can be found here
Why dont't you use a normal SelectOption List in Apex?
public List<SelectOption> getMyPicklist()
{
List<SelectOption> options = new List<SelectOption>();
List<Account> acc = [ Select Id, Name From Account Limit 10 ];
for(Account a : acc){
options.add(new SelectOption(a.Id,a.Name));
}
return options;
}
I had to update picklist with values from my database (and not from some visualforce page). So I authenticated account using Databasedotcom gem and it provides nice Api to iteract with Salesforce Objects (both Standard and Custom).
client.authenticate :token => "my-oauth-token", :instance_url => "http://na1.salesforce.com" #=> "my-oauth-token"
account = client.materialize("Account")
account_to_be_updated = account.find(account_id) # here account is same as Instance of Activerecord
account_to_be_updated.my_picklist = [value1; value2; value3; value4]
account_to_be_updated.save

Cakephp:How to validate my select options so that it restricts duplication of options selected

I have a selection drop down menu, and I want the user to select two options for a field in the database. The problem is how do I make it to disallow duplication of select options, currently it's saving all options even when they are the same.
Code in my add.ctp for the select options is:
echo $this->Form->select("ProgrammeChoice.programme_code.0",$finals);
echo $this->Form->select("ProgrammeChoice.programme_code.1",$finals);
And the variable $finals is bringing the select options from another table in the database, it's in the controller and the code is:
$finals = array_merge($filtered_programs,$non_preq_programs);
So please, I want help to validate my select menu to deny duplicate selections on submission.
Create a custom validation rule and compare the values as described here: http://book.cakephp.org/2.0/en/models/data-validation.html#adding-your-own-validation-methods
In the validation method your data is stored in $this->data.
It should look similar to this:
public function compare($field1) {
if($field1 === $this->data['ProgrammeChoice']['programm_code']['1']) {
return false;
}
return true;
}

Resources