Skip to main content
Arnaud Colas ha preguntado en #Apex
Hello,

I'm new with apex coding. I'm implementing somthing in order to define a table. This is my code :

CLASS :

 

public class dataTableControlllerApplet {

Integer NbMonth = 12;

private Id Id;

public Map<String, Object> inputFieldsMonth {get; set; }

public Map<Integer,Affair__c> inputFieldsLignes {get; set; }

public dataTableControlllerApplet(ApexPages.standardController controller){

}

public dataTableControlllerApplet(ApexPages.standardSetController controller){

initialisation();

}

private void initialisation() {

String Annee = YEAR(TODAY());

inputFieldsMonth = new Map<String, Object>();

for (Integer i = 1 ; i <= NbMonth ; i++) {

inputFieldsMonth.put('Month' + i + '__c', '0' + i + '/' + Annee);

}

inputFieldsLignes = new Map<Integer,Affair__c>();

integer i = 1;

integer g = 0;

for (Affair__c aff : [select z.name, z.month1__c, z.month2__c, z.month3__c, z.month4__c, z.month5__c, z.month6__c, z.month7__c, z.month8__c, z.month9__c, z.month10__c, z.month11__c, z.month12__c from Affair__c z ]){

for (Integer j = 1 ; j <= NbMonth+1 ; j++) {

if (j==1){

inputFieldsLignes.put('aff.name', aff.get('name'));}

else{

g = j-1;

inputFieldsLignes.put('aff.month'+g+'__c', aff.get('month'+g+'__c'));}

}

inputfieldsLignes.add(i, aff);

i++;

}

}

}

PAGE :

 

<apex:page standardController="Affair__c" extensions="dataTableControlllerApplet" recordSetVar="affairs" sidebar="false" docType="html-5.0">

<apex:form >

<apex:pageBlock >

<apex:pageMessages />

<apex:pageBlockButtons >

<apex:commandButton value="Save it here!" action="{!save}"/>

</apex:pageBlockButtons>

<apex:pageBlockButtons >

<apex:commandButton value="Or here :)" action="{!save}"/>

</apex:pageBlockButtons>

<table class="tableau" id="tableau" cellspacing="0" border="1" cellpadding="0">

<tr>

<td class="Noms" colspan="{!Affair__c.Name}">Affair Name</td>

<apex:repeat value="{!inputFieldsMonth}" var="fieldKey">

<td>

<apex:input value="{!inputFieldsMonth[fieldKey]}"/>

</td>

</apex:repeat>

</tr>

<apex:repeat value="{!inputFieldsLignes}" var="ligne">

<tr>

<apex:repeat value="{!inputFieldsLignes[ligne]}" var="donnee">

<td>

<apex:input value="{!inputFieldsLignes[ligne][donnee]}"/>

</td>

</apex:repeat>

</tr>

</apex:repeat>

</table>

<apex:pageBlockTable value="{!affairs}" var="a">

<apex:column value="{!a.name}"/>

<apex:column headerValue="Jan">

<apex:inputField value="{!a.Jan__c}"/>

</apex:column>

<apex:column headerValue="Jul">

<apex:inputField value="{!a.Jul__c}"/>

</apex:column>

<apex:column headerValue="Added">

<apex:inputField value="{!a.Add_to_Backlog__c}"/>

</apex:column>

<apex:column headerValue="StartDate">

<apex:inputField value="{!a.Start_Date__c}"/>

</apex:column>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>

[hr]

Then, I have these problems :

(page, line 0) : Unknown constructor 'dataTableControlllerApplet.dataTableControlllerApplet(ApexPages.StandardSetController controller)'

(class) :

24: Method does not exist or incorrect signature: void TODAY() from the type dataTableControlllerApplet

38 : Method does not exist or incorrect signature: void put(String, Object) from the type Map<Integer,Affair__c>

41 : Method does not exist or incorrect signature: void put(String, Object) from the type Map<Integer,Affair__c>

43 : Method does not exist or incorrect signature: void add(Integer, Affair__c) from the type Map<Integer,Affair__c>

First, I'm not sure if the "page-error" is real.

Then, related to "DATE" problem, I tried to change the "Annee"'s type...Successless.

For other things, I have no idea.

Thank you in advance!

 
1 respuesta
  1. 12 may 2017, 16:26
    The correct way to use YEAR() is System.TODAY().YEAR();

    Your map is of type<Integer,Affair__c> and you are populating it with <String,String>
0/9000