• Jyothsna Reddy
  • NEWBIE
  • 29 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 19
    Replies
Hello everyone.

I am struggling with this problem Please anyone try to help me............
Have a glance on code.
Here I have two records having m.Fieldtype as Combo.so 2 times getItems() will be called right?
So, options (returntype of getItems()) will store 2nd time value .And these values will be displayed in two SelectList values

( I want both values should be different)
How can i get this..?

Visualforce Code
<apex:selectList value="{!inputFields[m.Id]}" size="1" rendered="{!if(m.FieldType__c == 'Combo'  ,true,false)}" >
      <apex:selectoptions value="{!items}" ></apex:selectoptions>
</apex:selectList>

Controller Code:
   public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        comStr=null;
        for(Mapping__c map1:keylist){
            if(map1.FieldType__c=='Combo'){
                 comStr= map1.FieldValue__c;   
                 System.debug('comStr value is::::::::::'+comstr);
            } 
           }
        strList1=comStr.split(',');
        for(String str1:strList1){
            options.add(new SelectOption(str1,str1));
        }
        return options;
    }


Hi all,
I have MappingObject -----> Fields are::::::::::::::FieldName__c,FieldCaption__c && FieldType__c

Here I am trying to  get the  records based on FieldType__c(like ::::text,textarea). If FieldType is text it will show textbox.I did this finally using rendered.But my problem is  after submitting I am not getting the entered value.How can I solve this.
I am not even getting any error.
Please find the below code.I thought problem is storing the values.
<apex:pageBlock id="box">
  <apex:repeat value="{!inputFields}" var="m">
    <apex:outPutLabel value="{!if(m.FieldType__c == 'Text',m.FieldCaption__c,'')}"/>         
    <apex:inputText value="{!inputFields[m]}" rendered="{!if(m.FieldType__c == 'Text' ,true,false)}" />
    <!--<apex:outPutLabel value="{!if(m.FieldType__c == 'Textarea',m.FieldCaption__c,'')}"/>         
    <apex:inputtextarea value="{!inputFields[m]}" rendered="{!if(m.FieldType__c == 'Textarea',true,false)}" /> -->
  </apex:repeat>
  <apex:commandButton action="{!submitFieldData}"  value="Submit" id="button" rerender="box"/> {!strList}

Controller Code:
public class repeatandsave {

    public List<String> strList { get; set; }

    public Map<String,List<String>> outputFields { get; set; }
   
    public Map<Mapping__c,String> inputFields { get; set; }
    public List<Mapping__c> mapList{get;set;}
    public String str{get;set;}
    public repeatandsave(){
       strList=new List<String>();
       inputFields=new Map<Mapping__c,String>();
       mapList=new List<Mapping__c>();
       mapList=[SELECT FieldCaption__c,FieldName__c,FieldType__c,Name from Mapping__c where formname__c ='empform1']; 
       
       for(Mapping__c map1:mapList){
          System.debug(':::::::::::+before ++'+map1);
          inputFields.put(map1,'');
         
          System.debug(':::::::::::+after++'+map1);
          
       }
       System.debug('::::::::::::'+ inputFields.keyset());
        System.debug('::::::::::::::::values::::::::'+inputFields.values());
    
    }
    
     public PageReference submitFieldData() {
        System.debug('Inside submit:::::::::::'+maplist); 
        
         for(Mapping__c  map1 : mapList){
            System.debug('::::::::::::map1 values are::::::::::'+map1);
            inputFields.get(map1);
            System.debug('Map values are:'+inputFields.get(map1));
            //System.debug('::::::::::::::map1values are :::::::::::::::'+outputFields.get(map1.FieldName__c));
            //strList.add(outputFields.get(map1.FieldName__c));
         }/*
        for(String str:strList){
            System.debug('Added Elements are ::::::'+str);
        } 
         System.debug('In submitt::::::::::::');
        */
        return null;
    }
    
}



Screen Shot::::::::::::

User-added image
Hi
Visualforce Code :
<apex:page controller="StringListEx" showheader="false" >
  <apex:form >
     <apex:pageblock >
        Name <apex:inputtext value="{!firVal}"/>
        code <apex:inputtext value="{!secVal}"/>
        Color <apex:inputtext value="{!thirdVal}"/>
        Class <apex:inputtext value="{!fourthVal}"/>
        <apex:commandButton value="Display" action="{!dislay}"/>
     </apex:pageblock>
  </apex:form>
</apex:page>
Apex/Controller Code :
public with sharing class StringListEx {

    public StringListEx (){
   
    } 
    
    public List<String> strLst;
    public String firVal { get; set; }
    public String secVal { get; set; }
    public String thirdVal { get; set; }
    public String fourthVal { get; set; }
    public PageReference dislay() {
        System.debug('First element value::::::::::::::'+firVal);
        System.debug('Second value::::::::::::::'+secVal);
        System.debug('Third value::::::::::::::::'+thirdVal);
        System.debug('Fourth value:::::::::::::::'+fourthVal); 
        strLst.add(firVal);   
        strLst.add(secVal);   
        strLst.add(thirdVal);   
        strLst.add(fourthVal);
        return null;
    }  
}

While Adding values to array,I'm getting this error System.NullPointerException: Attempt to de-reference a null object  at line 17.
In debugging I am getting the values whatever I entered
.Then why it is showing Nullpointer exception


Hello everyone,
     Good Morning,
     Please have a glance on  the code and images .My main target is to add entered text values to an array/list/map.
 {!textarray} ----->But If you look to figure 2 I am getting values in textarray .
But I am getting only last entered value i.e., eeeee. Previously entered values are getting replaced.
I think I need to add these "textArray" values to List.
To acheive that I changed the datatype of textarray as Map<String,String>  Then I got the error as shown below
[EXTERNAL]|System.TypeException: Invalid conversion from runtime type String to MAP<String,String>
....................................

VisualForce Code:
<apex:page controller="repeatandsave" showHeader="false">
  <apex:form >
   <apex:pageBlock >
    <apex:repeat value="{!con}" var="a" id="re">
         <apex:inputtext value="{!textarray}" id="in" >
            <!-- <apex:actionsupport event="onblur" action="{!loopList}"  rerender="re"/>-->
         </apex:inputtext>
         <br/>
    </apex:repeat>
    <apex:commandButton value="Save" action="{!myaction}"/>
   </apex:pageBlock>
  </apex:form>
</apex:page>
Controller/Apex Code:

public class repeatandsave {
    public Map<String,String> strList;
    public String textarray {get; set;}
    Map<Integer, Contact> mapToContact = new Map<Integer, Contact>();
    public list<contact> myconlist{set;get;}
   //Constructor
    public repeatandsave(){
        Integer i = 0;
        for (Contact a :[Select Id, Name From Contact limit 5]) {
            mapToContact.put(i, a);
            i++;
        }
       
    }
    
    public Map<Integer,Contact> getcon (){    
        return mapToContact;
    }
    //save action
    public void myaction(){
      
        system.debug('action invoked::::::::::+textarray'+textarray);
    }
}
ScreenShot:
                           fig 1
First Image
User-added image
                       fig2


Hi all,

Here I am using Custom controller. 

Since there are 5  records in  mappingList  .It is showing 5 textboxes.How can I add the text entered in textboxes to List.
I am getting only the last value in controller.Here I dontknow how to add these values to array....
<apex:pageBlock >
    <apex:repeat value="{!mappingsList}" var="a">
         
         <apex:inputText value="{!textarray}" id="in"/><br/>
    </apex:repeat>
   <apex:commandButton value="Save" action="{!myaction}"/>
</apex:pageblock>



-----Please  attach  the printscreen----------
 Ps
Hello,
What is the SuperClass in apex ? In Java Object is super class.
one way of intializing/decalring an object is below
Object obj ;
public className(){
obj =new Sample();
}
other way is Sample sampObj=new Sample();

Now ,Comming to salesforce ,How can i declare the Object.
I know one way is Sample__c obj=new Sample__c();
I want to use super class while initializing.... 



Hi,
I had written the IF Condition in VF page  as below
<apex:column value="{! If(m.Name=='sai' ,true,false) }"/>

But I am getting the " Error is in expression '{!If(m}' "evenI had given Correct syntax.

How can i solve this?
 
Hello everyone.

I am struggling with this problem Please anyone try to help me............
Have a glance on code.
Here I have two records having m.Fieldtype as Combo.so 2 times getItems() will be called right?
So, options (returntype of getItems()) will store 2nd time value .And these values will be displayed in two SelectList values

( I want both values should be different)
How can i get this..?

Visualforce Code
<apex:selectList value="{!inputFields[m.Id]}" size="1" rendered="{!if(m.FieldType__c == 'Combo'  ,true,false)}" >
      <apex:selectoptions value="{!items}" ></apex:selectoptions>
</apex:selectList>

Controller Code:
   public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        comStr=null;
        for(Mapping__c map1:keylist){
            if(map1.FieldType__c=='Combo'){
                 comStr= map1.FieldValue__c;   
                 System.debug('comStr value is::::::::::'+comstr);
            } 
           }
        strList1=comStr.split(',');
        for(String str1:strList1){
            options.add(new SelectOption(str1,str1));
        }
        return options;
    }


Hi all,
I have MappingObject -----> Fields are::::::::::::::FieldName__c,FieldCaption__c && FieldType__c

Here I am trying to  get the  records based on FieldType__c(like ::::text,textarea). If FieldType is text it will show textbox.I did this finally using rendered.But my problem is  after submitting I am not getting the entered value.How can I solve this.
I am not even getting any error.
Please find the below code.I thought problem is storing the values.
<apex:pageBlock id="box">
  <apex:repeat value="{!inputFields}" var="m">
    <apex:outPutLabel value="{!if(m.FieldType__c == 'Text',m.FieldCaption__c,'')}"/>         
    <apex:inputText value="{!inputFields[m]}" rendered="{!if(m.FieldType__c == 'Text' ,true,false)}" />
    <!--<apex:outPutLabel value="{!if(m.FieldType__c == 'Textarea',m.FieldCaption__c,'')}"/>         
    <apex:inputtextarea value="{!inputFields[m]}" rendered="{!if(m.FieldType__c == 'Textarea',true,false)}" /> -->
  </apex:repeat>
  <apex:commandButton action="{!submitFieldData}"  value="Submit" id="button" rerender="box"/> {!strList}

Controller Code:
public class repeatandsave {

    public List<String> strList { get; set; }

    public Map<String,List<String>> outputFields { get; set; }
   
    public Map<Mapping__c,String> inputFields { get; set; }
    public List<Mapping__c> mapList{get;set;}
    public String str{get;set;}
    public repeatandsave(){
       strList=new List<String>();
       inputFields=new Map<Mapping__c,String>();
       mapList=new List<Mapping__c>();
       mapList=[SELECT FieldCaption__c,FieldName__c,FieldType__c,Name from Mapping__c where formname__c ='empform1']; 
       
       for(Mapping__c map1:mapList){
          System.debug(':::::::::::+before ++'+map1);
          inputFields.put(map1,'');
         
          System.debug(':::::::::::+after++'+map1);
          
       }
       System.debug('::::::::::::'+ inputFields.keyset());
        System.debug('::::::::::::::::values::::::::'+inputFields.values());
    
    }
    
     public PageReference submitFieldData() {
        System.debug('Inside submit:::::::::::'+maplist); 
        
         for(Mapping__c  map1 : mapList){
            System.debug('::::::::::::map1 values are::::::::::'+map1);
            inputFields.get(map1);
            System.debug('Map values are:'+inputFields.get(map1));
            //System.debug('::::::::::::::map1values are :::::::::::::::'+outputFields.get(map1.FieldName__c));
            //strList.add(outputFields.get(map1.FieldName__c));
         }/*
        for(String str:strList){
            System.debug('Added Elements are ::::::'+str);
        } 
         System.debug('In submitt::::::::::::');
        */
        return null;
    }
    
}



Screen Shot::::::::::::

User-added image
Hi
Visualforce Code :
<apex:page controller="StringListEx" showheader="false" >
  <apex:form >
     <apex:pageblock >
        Name <apex:inputtext value="{!firVal}"/>
        code <apex:inputtext value="{!secVal}"/>
        Color <apex:inputtext value="{!thirdVal}"/>
        Class <apex:inputtext value="{!fourthVal}"/>
        <apex:commandButton value="Display" action="{!dislay}"/>
     </apex:pageblock>
  </apex:form>
</apex:page>
Apex/Controller Code :
public with sharing class StringListEx {

    public StringListEx (){
   
    } 
    
    public List<String> strLst;
    public String firVal { get; set; }
    public String secVal { get; set; }
    public String thirdVal { get; set; }
    public String fourthVal { get; set; }
    public PageReference dislay() {
        System.debug('First element value::::::::::::::'+firVal);
        System.debug('Second value::::::::::::::'+secVal);
        System.debug('Third value::::::::::::::::'+thirdVal);
        System.debug('Fourth value:::::::::::::::'+fourthVal); 
        strLst.add(firVal);   
        strLst.add(secVal);   
        strLst.add(thirdVal);   
        strLst.add(fourthVal);
        return null;
    }  
}

While Adding values to array,I'm getting this error System.NullPointerException: Attempt to de-reference a null object  at line 17.
In debugging I am getting the values whatever I entered
.Then why it is showing Nullpointer exception


Hi all,

Here I am using Custom controller. 

Since there are 5  records in  mappingList  .It is showing 5 textboxes.How can I add the text entered in textboxes to List.
I am getting only the last value in controller.Here I dontknow how to add these values to array....
<apex:pageBlock >
    <apex:repeat value="{!mappingsList}" var="a">
         
         <apex:inputText value="{!textarray}" id="in"/><br/>
    </apex:repeat>
   <apex:commandButton value="Save" action="{!myaction}"/>
</apex:pageblock>



-----Please  attach  the printscreen----------
 Ps
Hello,
What is the SuperClass in apex ? In Java Object is super class.
one way of intializing/decalring an object is below
Object obj ;
public className(){
obj =new Sample();
}
other way is Sample sampObj=new Sample();

Now ,Comming to salesforce ,How can i declare the Object.
I know one way is Sample__c obj=new Sample__c();
I want to use super class while initializing.... 



Hi,
I had written the IF Condition in VF page  as below
<apex:column value="{! If(m.Name=='sai' ,true,false) }"/>

But I am getting the " Error is in expression '{!If(m}' "evenI had given Correct syntax.

How can i solve this?