Displaying Image depending on a value in oracle adf - oracle-adf

we are developing a web application using
Oracle ADF
jDeveloper
Our Requirement: we have a table called Departments with two columns "deptId and Employees". We have created Entity and view objects for Departments table. We are using data control of view object to create a table in jsf page. Our desired table is as below. We drag and drop first column. And we need to create another column that should contain green image if employees in the department is less than 100(for ex) otherwise red image. Our main requirement is we have show image depending on some condition.
Thanks in advance.

Or in a single line with conditional EL:
<af:image source=
"#{row.bindings.EmployeeCount.inputValue ge 100 ? '/red.png' : '/green.png'}"/>

Our main requirement is we have show image depending on some condition.
My assumption is that you already have an attribute in your View object which reflects the data you depend on (the number of employees as EmployeeCount, in this case). Then, you can simply use the rendered attribute together with an EL expression to display different images in your table:
...
<af:column headerText="Icon" id="c1">
<af:image source="#{resource['images:green.png']}" id="i1"
rendered="#{row.bindings.EmployeeCount.inputValue lt 100}"/>
<af:image source="#{resource['images:red.png']}" id="i2"
rendered="#{row.bindings.EmployeeCount.inputValue ge 100}"/>
</af:column>
...

Related

How to show recently record list on my custom visualforce page?

The sObject's record list
Hey, I have a question, when I click a sObject's tab it will present a standard page. The picture shows the recently record list, is it a standard function like "apex:listViews" mark-up tag? I want to achieve this function in my own custom page. How do I do this?
I don't think there's a dedicated VF tag for it (aside from some very specialised cases like Knowledge and Ideas-related tags). But you can manually query it from database and display in <apex:pageBlockTable>.
There's a table with "recently viewed everything, across all objects" (think of it like "Recent Items" sidebar in clasic SF UI): https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_recentlyviewed.htm
And also most objects will have a LastViewedDate field so you should be able to do
SELECT Name
FROM Restaurant__c
WHERE LastViewedDate != null
ORDER BY LastViewedDate DESC

angular-js + tr-ng-grid - how to change the displayed table's schema?

I have a simple Angular-JS page that uses tr-ng-grid tag
<div ng-controller="TableDataCtrl">
<div id="tableview_element">
<table tr-ng-grid="" items="data"
ng-show="data_available()">
</table>
</div>
{{str_data}}
</div>
Whenever user clicks on a link, the application should display a different table. The controller is able to obtain the JSON data from the server using HTML get. 'str_data' is stringified form of the JSON data. That seems correct always.
But the tr-ng-grid does not ever update the table's schema. It seems to lock on to the very first table that is displayed with it. The whole table may be hidden or displayed using ng-show(), but then the column headings don't get modified to that of the newly loaded table.
To be very clear: Say you have two tables, birds and mammals. If the first table is a list of all birds and birds-attributes, tr-ng-grid displays the table by automatically figuring out the column headings. If the user clicks on mammals then on the page, the mammal data gets loaded, but tr-ng-grid is still looking for bird-attributes in a mammals table which has a different set of columns (and a few common columns like id and name)
How would one force tr-ng-grid to erase the current template and construct a whole new table?
One method is of course to keep every table in its own controller, and own HTML element. Is there a simpler way? or is there an alternative to tr-ng-grid that supports such a full-fledged table view refresh?
Seems like, grid headers are initialized only once.
One solution to solve your problem is to re-compile the grid whenever the data is changed.
Here is the updated plunker. http://plnkr.co/edit/34nUGmopB8q4GWQ9uF57?p=preview

Adding fields to a Junction Object from one of the Master-Detail relationships

In a Salesforce Junction object can I reference fields from the two Master-Detail relationships in formulas and/or the User Interface or am I going to have to switch to Apex code? I can write the apex, but I try to use the built in tools as much as possible :).
To use the examples from the Trailhead tutorials I have
1. A Job Position Object (Project Mananger, Sr Developer, etc).
2. A Posting Website Object (Monster.com, Dice.com, etc).
3. A "Job Posting" Junction Object to link the two.
Let's say I add a field to the Job Position Object called "Close Date" to keep track of the date the position closes. Can I display this field on the layout page of the Job Posting Junction object without using Apex code and/or a custom VisualForce page?
Thanks!
You can definitely do that. You can use a formula field and just reference the relationship name of the object and the field name (so for example something like Job_Position__r.Close_Date__c), or if you prefer you can use the "Insert Field" button when creating the formula which will allow you to select the object/field you want through the UI.

displaying a particular field of a related node with Entity Reference

Using Drupal 7, using views i have created a related 'videos' block for various page nodes. I can get the title to show but i can't see how i can just choose to show the 'thumbnail' field for related videos. I'm using the entity reference module. Is this possible within the view?
heres the example...http://testing.odvod.ca/bishop/what-we-do/our-approach
i figured it out...
in the view i created a relationship choosing:
--Entity Reference: Referenced Entity
--A bridge to the Content entity that is referenced via field_related_videos
The added the field to view and chose the reference the desired field content with the relationship drop down.
this tutorial helped: Using Entity Reference in Views

Associating an uploaded File (id) with another table

I'm using Filestore to make uploads in a form.
It's a great implementation but I've a doubt about associating that file uploaded with a register in a table.
When I run the filestore.001.sql, it add 4 tables in Database (filestore_image, filestore_file, filestore_volume, filestore_extension).
Then in anoter table I have:
id
field1
idfile
I was thinking in how to do that association when I submit the form.
Maybe a dsql() and then selecting the last inserted file, but I don't know if this is the best option.
Thanks
Alejandro
When you add a image field to a form, it will return you ID (or list of uploaded file id's) on submission. So theoretically user can upload image and never submit form, hence it wouldn't be associated.
You can have the following table:
id
name
picture_id
and define picture as type image, there should be examples on the site - it will automatically receive ID from the filestore_file table.
There is another way you can do and it's exactly how Filestore_Image is being built. You can make your own model, and link it with necessary image and use that for your image field. Since it's your model, you can now control what happens before inserting, you can override beforeInsert and afterInsert events to build the proper associations.
Both methods have their own uses, pick the one which you like.

Resources