0

I'm trying to generate a Visualforce page for a certain data entry with certain controls and functionality which is essentially a dynamic controller page. Below is how I generate a page block.

        Component.Apex.PageBlock dynPageBlock = new Component.Apex.PageBlock();

        List<Schema.FieldSetMember> list_of_fields = getFieldsToDisplay();
        Component.Apex.PageBlockSection pbs = new Component.Apex.PageBlockSection();
        pbs.columns = 1;

        for(Schema.FieldSetMember fld : list_of_fields){
           // input field
           Component.Apex.InputField input_field = new Component.Apex.InputField();
           input_field.expressions.value = '{!FormObject.' + fld.getFieldPath() +'}';
           input_field.id = fld.getFieldPath();
           pbs.childComponents.add(input_field);

After this step, I wish to create a ApexPage which I need a API method to save it under APEX pages. Is this something possible to achieve in VisualForce? Curious about it. Thanks.

1 Answer 1

1

Yes, it is doable via Apex. You will need to use metadata API in this case. Andrew has a library for it: https://github.com/financialforcedev/apex-mdapi . You can use it to generate your VF page. But sorry I don't have a sample code for it. But it should point you to where to start.

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.