4

I'm using a custom auto-complete component as described here:

auto-complete

I've abstracted the code in the AutoCompleteController into a separate dynamic query utility, so in the auto complete controller I can just call the dynamic utility class from the auto complete controller like this:

global class AutoCompleteController {

@RemoteAction
global static SObject[] findSObjects(string obj, string qry, string addFields, string profilename) 
{
    return DynamicQueryBuilderUtilty.buildQuery(obj, qry, addFields, profilename);
}   

}

This works fine and the query utility can be used in other situations. I'm wondering if I can abstract further given the following scenario. There are a variety of applications in the org for many different divisions and business groups. Each application uses its own service layer to make calls to the database.

VFPage >> Controller >> Service Layer >> Database

Is there a way to structure the component so it can be encapsulated in different service layer classes and just pass the appropriate arguments to the auto complete controller?

Thanks for any help.

  • But this component is already reuseable. I am not understanding your goal. can u clear more on this. – Ankuli Apr 18 '15 at 12:58
  • 1
    Can you provide an example of another use case that needs to call the code but cannot call it as written? I do not understand what you are asking. – Jason Clark Apr 19 '15 at 4:37
0

If I have it got correctly.

You can create a dynamic component and reuse it(say passing attribute value while creating dynamic component, the way you are doing at reusable component)

<apex:page controller="SimpleDynamicController">
    <apex:dynamicComponent componentValue="{!dynamicDetail}" />
</apex:page>

/* Controller */
public class SimpleDynamicController extend serviceLayer{

//serviceLayer has the abstract method.
//so every vf page controller can override this method, and assign the appropriate value
// like object Name, fields for autocomplete etc.

    public override Component.Apex.Detail getDynamicDetail() {
        Component.Apex.ResuableCompoenet RC = new Component.Apex.ResuableCompoenet();
        RC.attribute1 = 'fields';
        RC.attribute2 = false;
        return RC;
    }

}


//component code
<apex:component ......>
    <apex:attribute name="attribute1" ...... />
    <apex:attribute name="attribute2" ...... />

</apex:componenet>
  • @dman : is this the solution you was looking for ? – Ankuli Apr 20 '15 at 12:45
  • Hi @Ankuli, thank you for your help with this. I'm working on implementing your solution. I will respond back with details if I cannot get it to work as you suggested. – Dman100 Apr 21 '15 at 2:37
  • 1
    I didn't downvote your answer. I just removed the line where you explicitly asked for an upvote. – Brian Mansfield Apr 22 '15 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.