You need to sign in to do that
Don't have an account?
How to display seperate table for one object
Hi developers,
Am creating a detailed page of my custm object onto a vf page, but I want it displayed that each field will be displayed on table of its own ,
The Object Constituent_Assembly has different types of list values like (Engine 1, Engine2, Landing Gear - Left, Landing Gear - Right),each of these has different attribute value like the Serial Number, Part Number and Date of creation, Date of workshop vist and so on. So Displaying them in the VF page I want the Engine parts altogether and the Landing gear together and only the upto date one to be displayed
Here is the part of selecting the Engine but just couldnt figure how to give the date condition on to it.
public List<Constituent_Assembly__c> getConstitutenAssemblies(Aircraft__c aircraft)
{
List<Constituent_Assembly__c> constAssemb = new List<Constituent_Assembly__c>();
if (aircraft!=null)
{
Id aircraftID = aircraft.ID;
constAssemb = [select id,name,Part_Number__c,Serial_Number__c, Model__c,CSN__c, TSN__c, CSLV__c, TSLV__c, Life_Limit__c from
Constituent_Assembly__c where Attached_Aircraft__c = :aircraftID AND
(Type__c = 'Engine 1' or Type__c = 'Engine 2')];
}
return constAssemb;
}
Hope someone can help me with it.
Thanks in Advance and regards
S.Aj
Change Set<Type> to Set<string>
Ihave updated it use this one
This method returns lastmodified engine type record , if it works riplicate it for Gear Type as well , if any issue let me know.
All Answers
Two suggestion
1) Use two different SOQL , one for Engine another for Gear part and use geeter methosds like you have used in your code sample
2)Get all records with one query
Use a for loop and cretae two different list out of List<Constituent_Assembly__c> constAssemb
like
List<Constituent_Assembly__c> constAssembEngine = new List<Constituent_Assembly__c>();
List<Constituent_Assembly__c> constAssembGear = new List<Constituent_Assembly__c>();
Please ask if any issues in it.
I left this part of the code intact except for removing the checking the type
public List<Constituent_Assembly__c> getConstitutenAssembly(Aircraft__c aircraft)
{
List<Constituent_Assembly__c> constAssemblies = new List<Constituent_Assembly__c>();
if (aircraft!=null)
{
Id aircraftID = aircraft.ID;
constAssemblies = [select id,name,Part_Number__c,Serial_Number__c, Model__c, Type__c, CSN__c, TSN__c, CSLV__c, TSLV__c, Life_Limit__c from
Constituent_Assembly__c where Attached_Aircraft__c = :aircraftID];
}
return constAssemblies;
}
Added this in controller part of the code
public AircraftController () {
other parts of the code are omitted in here
ConstAssemb = getConstitutenAssembly(parentAC);
if(ConstAssemb.Type__c == 'Engine 1' || ConstAssemb.Type__c == 'Engine 2'){
ConstAssembEngine.add(ConstAssemb);
}else if(ConstAssemb.Type__c == 'Landing Gear - Center Main' || ConstAssemb.Type__c == 'Landing Gear - Left Main'
|| ConstAssemb.Type__c == 'Landing Gear - Right Main'||ConstAssemb.Type__c == 'Landing Gear - Nose'){
ConstAssembGear.add(ConstAssemb);
}
}
And added 2 more get methods for each one
public List<Constituent_Assembly__c> getConstAssembEngine(){
return ConstAssembEngine;
}
public List<Constituent_Assembly__c> getConstAssembGear(){
return ConstAssembGear;
}
But am getting this error
Error: Compile Error: Incompatible element type LIST<Constituent_Assembly__c> for collection of SOBJECT:Constituent_Assembly__c
ConstAssembEngine , ConstAssembGear are lists that are declared in the beginning of the code with rest of the variables before the constructor.
What could I have done wrong?
Thanks and Regards
S.aj
ConstAssemb = getConstitutenAssembly(parentAC); // This gives you a list
if(ConstAssemb.Type__c == 'Engine 1' || ConstAssemb.Type__c == 'Engine 2'){
ConstAssembEngine.add(ConstAssemb); //Here you are adding a List instead you should add only a single item of list as ConstAssembEngine is a List<Constituent_Assembly__c> and you can add Constituent_Assembly__c records in it not any list of Constituent_Assembly__c
You should use a for loop over list and then check condition for engine type and gear and then add records in the appropriate list.
Please ask if any doubt over this.
I went for the first solution you had given and this is what I did
public AircraftController () {
ConstAssembEngine = getConstitutenAssemblyEngine(parentAC);
ConstAssembGear = getConstitutenAssemblyGear(parentAC);
}
public List<Constituent_Assembly__c> getConstitutenAssemblyEngine(Aircraft__c aircraft)
{
List<Constituent_Assembly__c> constAssemblies = new List<Constituent_Assembly__c>();
if (aircraft!=null)
{
Id aircraftID = aircraft.ID;
constAssemblies = [select id,name,Part_Number__c,Serial_Number__c, Model__c, Type__c, CSN__c, TSN__c, CSLV__c, TSLV__c, Life_Limit__c from
Constituent_Assembly__c where Attached_Aircraft__c = :aircraftID AND
(Type__c = 'Engine 1' or Type__c = 'Engine 2')];
}
return constAssemblies;
}
public List<Constituent_Assembly__c> getConstitutenAssemblyGear(Aircraft__c aircraft)
{
List<Constituent_Assembly__c> constAssemblies = new List<Constituent_Assembly__c>();
if (aircraft!=null)
{
Id aircraftID = aircraft.ID;
constAssemblies = [select id,name,Part_Number__c,Serial_Number__c, Model__c, Type__c, CSN__c, TSN__c, CSLV__c, TSLV__c, Life_Limit__c from
Constituent_Assembly__c where Attached_Aircraft__c = :aircraftID AND
(Type__c = 'Landing Gear - Center Main' or Type__c = 'Landing Gear - Left Main'
or Type__c = 'Landing Gear - Right Main' or Type__c = 'Landing Gear - Nose')];
}
return constAssemblies;
}
public List<Constituent_Assembly__c> getConstAssembEngine(){
return ConstAssembEngine;
}
public List<Constituent_Assembly__c> getConstAssembGear(){
return ConstAssembGear;
}
And this worked out pretty well, although it gets more codin in it but yes it works, I need to verify one more thing I dont want every instance of the types to be displayed only the last one created for each one of the type, as mutliple values for these fields, So how can the comparison made?
Thanks and regards
S.aJ
I am updating one of them
Make similar chenge in other one too , it will solve your problem , please ask if any issue in it.
What exactly does this method return ? Besides it s givng out error
Error: Compile Error: Invalid type: Type
I just couldn't make out what really is happening
Thanks and Regards
S.Aj
Change Set<Type> to Set<string>
Ihave updated it use this one
This method returns lastmodified engine type record , if it works riplicate it for Gear Type as well , if any issue let me know.
Thanks for the help, Solved my doubts and confusions
Regards
S.Aj