How to create a table in adf with variable no of columns - oracle-adf

Hello I am developing a web application using ADF (jdeve11.1.2.4). I know how to populate a table programatically from this post Programmatic ADF Table
But in the above post the no of columns are fixed (It is bean structure). But I cannot use the above post. Because I need to create a table with 'n' no-of columns. Means Columns are not fixed. Some times the columns may be 4 or some times the columns may be 7 and what ever it may be. Suppose I have two sqls and both contains differnt no of columns.
Ex: (suppose student is a table)
select id from student
select id,name from student
so in the above two sqls no of columns are diffent. I need to show the resul set of the above queries in a tablular format.
Please help me how I can achieve this.
Thanks in advance.

I wonder if declarative mode view objects would help? Blog here. So the query is not built until the UI is gen'd. You could dynamically generate the table and insert columns and then bind to the VO.

That's quite complex to do and it may require some extra study:
create a programatic view object by passing your sql statement using:
ApplicationModuleImpl.createViewObjectFromQueryStmt(java.lang.String voName,java.lang.String query)
try to construct af:columns in a loop:
<af:table value="#{bindings.EmployeesView1.collectionModel}" .. id="t1">
<af:iterator id="i1" value="#{bindings.EmployeesView1.attributesModel.attributes}" var="column" rows="0">
<af:column headerText="#{column.label}" id="c1">
<af:outputText id="d1" attributeModel="#{column}" value="#{row.bindings[column.name].inputValue}" />
</af:column>
</af:iterator>
</af:table>

Related

ODI 12c CUSTOM_TEMPLATE extract option not working

I'm using the CUSTOM_TEMPLATE extract option on the source table to force a select actually from another table. Which then would be used by a custom IKM I'm using in order to get the column list of the "forced" table with the odiRef.getColList API. But the template select query is not considered at all in the execution, so the IKM still gets the columns from the original table and I don't need them.
The code in the CUSTOM_TEMPLATE is:
select *
from <%=odiRef.getObjectName("L", "#V_OFFL_TABLE_NAME", "OFFLOAD_AREA_HIST", "DWH_LCL", "D") %>
where src_date_from_dt = to_date('V_OFFL_TRANSFER_DATE','YYYY-MM-DD')
The code in the SOURCE tab of the custom IKM I made is:
select <%=odiRef.getSrcColList("","[COL_NAME]",",\n","")%>
from <%=odiRef.getObjectName("L", "#V_OFFL_TABLE_NAME", "OFFLOAD_AREA_HIST", "DWH_LCL", "D") %>
where src_date_from_dt = to_date('V_OFFL_TRANSFER_DATE','YYYY-MM-DD')
in this case I'm trying with odiRef.getSrcColList in the IKM, but I;ve also tried with odiRef.getColList - same result.
Try to create a Dummy Datastore in the Model where you have that table.
You can add dummy or general attributes into that Datastore(Var1,Var2,Var3...Num1,Num2..etc).
Drag this datastore to the source area and add the CUSTOM_TEMPLATE there.
*Make sure this dummy is having the same logical schema as the table in your custom query.
This can also work with multi table query.

Access a field from another table using the object relation

I am new to SalesForce and SOQL so sorry in advance if the question has already been answered, if yes link it to me.
The aim of my SOQL query is to get all the contract information to generate PDF.
There are tables: Contract, Contact and Account
In the Contract table there are fields: Maitre_d_apprentissage__c, MaitreApprentissageNom1__c, MaitreApprentissagePrenom1__c, Apprenti__c, ApprentiNom__c, ApprentiPrenom__c
There are relationships:
Apprenti__r which link Apprenti__c to Contact table
Maitre_d_apprentissage__r which link Maitre_d_apprentissage__c to Contact table
When I looked at table, I saw that MaitreApprentissageNom1__c was equal to Maitre_d_apprentissage__r.LastName and ApprentiNom__c was equal to Apprenti__r.LastName. So I conclude I could get other information of Apprenti__c and Maitre_d_apprentissage__c from the Contact Table following the same principle. So I added to my query Apprenti__r.Date_de_naissance__c and Maitre_d_apprentissage__r.Date_de_naissance__c to get the Date_de_naissance__c field which is in my Contact table.
I see in the results that the query succeeds in getting the information but some values have changed column (lines 6 and 7), you can see the difference between query 1 and query 2. In the first query I only return the Apprenti__r.Date_de_naissance__c and in the second query I return Apprenti__r.Date_de_naissance__c and Maitre_d_apprentissage__r.Date_de_naissance__c
Query 1:
SELECT ApprentiNom__c, ApprentiPrenom__c, Apprenti__r.Date_de_naissance__c, MaitreApprentissageNom1__c, MaitreApprentissagePrenom1__c
FROM Contract
Result 1:
Query 2:
SELECT ApprentiNom__c, ApprentiPrenom__c, Apprenti__r.Date_de_naissance__c, MaitreApprentissageNom1__c, MaitreApprentissagePrenom1__c, Maitre_d_apprentissage__r.Date_de_naissance__c
FROM Contract
Result 2:
I would like to understand from where is coming the problem and how to correct it. Thank you in advance.
It's possible that it's just your query editor displaying stuff incorrectly. You can see it got confused with 2 lookups to Contact table, why there's even a column header "Contact.Date_de_naissance__c" (and why it's there twice). And they aren't shown in the order you requested...
What editor you're using? You could try built-in "Developer Console" or http://workbench.developerforce.com/
What do you need it for? In Apex order of fields won't matter, in REST API query the values fetched via lookup will come as JSON sub-objects so there will always be a way to figure out exactly which value is coming from which relation.
In Dev Console try to run this and check if it solves your fears:
System.debug(JSON.serializePretty([SELECT
ApprentiNom__c, ApprentiPrenom__c,
Apprenti__r.Date_de_naissance__c,
MaitreApprentissageNom1__c, MaitreApprentissagePrenom1__c,
Maitre_d_apprentissage__r.Date_de_naissance__c
FROM Contract]));
Then add Maitre_d_apprentissage__r.LastName to query and see what changed, what stayed as is.

Read Only Table displays foreign key instead of details

Summarize the problem
So I have a Department Table which has a column Location ID which references a Location Table.
FYI: (Department.locationID = Location.LocationID)
Now on my UI page when I drag and drop the department collection to make a table it displays the locationID instead of the location name. My end users won't understand Location ID, they'll need to see the locationName.
Provide background including what you've already tried
On my Department VO, I have referenced the locationID to a LOV so that it displays the LocationName. When the table is updatable, I have no issues, but when the table is read only the ID is being displayed instead of name.
I have read few blogs where they suggest to make the table column SelectOneChoice. Find the code snippet taken from my jsf page below.
Show some code
<af:column headerText="#{bindings.Departments1.hints.DepartmentLocationId.label}" id="c6">
<af:selectOneChoice value="#{row.DepartmentLocationId}"
shortDesc="#{bindings.Departments1.hints.DepartmentId.tooltip}"
id="soc1" readOnly="true">
<af:convertNumber groupingUsed="false" pattern="#{bindings.Departments1.hints.DepartmentLocationId.format}"/>
</af:selectOneChoice>
<!-- <af:outputText value="#{row.DepartmentLocationId}"
shortDesc="#{bindings.Departments1.hints.DepartmentLocationId.tooltip}" id="ot6">
<af:convertNumber groupingUsed="false" pattern="#{bindings.Departments1.hints.DepartmentLocationId.format}"/>
</af:outputText> -->
</af:column>
Describe expected and actual results including any error messages
After making the above changes (I commented out "outputText" section and added the "selectOneChoice" section) my location column doesn't display anything.
My expected output is for the table to display Location Name and not locationID.
I'm using JDeveloper 12c.
So just in case, anyone else faces the same issue, here is what I did as a workaround. It's not the exact solution to the above problem, but it works.
Instead of relying on VO based on one EO, I made a VO that's based on two EOs. the DepartmentEO and LocationEO. In the VO layer, both EOs should also be related with an association.
Now my DepartmentVO has an extra attribute called LocationName. On the UI front, I hide my LocationID and instead display the LocationName.

Laravel show records as flat array or single record

I have 2 column in my table setting
with the following values
KEY VALUE
company ABC
phone 14344
address Somerset City
I need to display this like a single record or a flatten
array in the view/blade page
something like
{{$sett->company}}
{{$sett->phone}}
or an array with lookup
{{$myarray('company')}}
{{$myarray('phone')}}
The idea is if I add another settings like contact us email address
for my website I don't want to add another column.
I know this is achievable in controller by creating different variable
and executing different query but I'm kind of looking for some options here.
Thanks for the help really appreciated.
You can use $settings->pluck('value', 'key') to get your result. Read more here: https://laravel.com/docs/5.4/collections#method-pluck

(VB2010 and ms Access) creating the query using INNERJOIN, select a field, and put the result as Display Member of combobox

before asking i wanna to show my tables and their relationships(created with ms access 2007)
here is the schema :
https://plus.google.com/photos/113802558354450440804/albums/5988059068393888337/5988059068667446962?banner=pwa&pid=5988059068667446962&oid=113802558354450440804
in this case, i create 3 combo boxes in VB2010 :
cbx_major(binded to MAJOR table)|major_id as the VALUE MEMBER, major_name as DISPLAY MEMBER
cbx_student(binded to STUDENT table)|student_id as the VALUE MEMBER, student_name as DISPLAY MEMBER
cbx_course( this is the question )
And here is the scenario :
first, i must choose what major is at cbx_major
second, the cbx_student will instruct the STUDENT table to select the student_name where major is equal to the selected value of cbx_major and set that query result as the DISPLAY MEMBER of cbx_student(this is done succesfuly without writing any code )
(this is the question)then the last, i want to set the cbx_course to display the course_name where student_id is equal to cbx_student.
i have done a lot of effort to do this :
i opened the combobox tasks menu and choose the student_course table and trying to create the query but it results "the schema returned by the new query differs from the base query"
i created the query in access by Joinning the table STUDENT_COURSE and COURSE using INNER JOIN then i bind the cbx_course to that query but it results wrong display.
i opened the xsd file then i create the query there but results wrong result
all those effort does not work.
i want to solve this case without writing code but using a technique such setting the taskbar menu, is it possible ? any idea? thanks so much for the attention

Resources