You need to sign in to do that
Don't have an account?
Unable to get records inserted in second VF page
Hello All,
public pagereference Save()
{
widgetpro = new C_P_Widgets__c();
for(integer i=0; i<selectlayout.size(); i++) {
widgetpro.Widget_Category__c = Name1;
widgetpro.Name = Username ;
if(val != null) {
val = val+ '<widget Image="' + selectlayout[i].Image1 + '" FieldLabel="' + selectlayout[i].label1 + '" result="' + selectlayout[i].result + '"/></widget>' ;
}
else {
val = '<widget Image="' + selectlayout[i].Image1 + '" FieldLabel="' + selectlayout[i].label1 + '" result="' + selectlayout[i].result + '"/></widget>' ;
}
widgetpro.Displayed_Values__c = val;
}
insert widgetpro;
wid = widgetpro.id;
PageReference page = new PageReference('/apex/widgetpageview?id='+wid);
page.setRedirect(true);
return page;
}
Here I'm saving the values and redirecting it to second vfpage and my vf page and controller class is
<apex:pageblockSection title="Widget Details" collapsible="false" columns="1">
<apex:pageblocktable value="{!widdata}" var="w">
{!w.Name}
<apex:column value="{!w.Name}" headerValue="Widget Name"/>
<apex:column value="{!w.Widget_Category__c}" headerValue="Category"/>
<apex:column value="{!w.Displayed_Values__c}" headerValue="Result"/>
</apex:pageblocktable>
</apex:pageblockSection>
public class widgetpageview1 {
public string wid{set;get;}
public widgetpageview1()
{
wid=apexpages.currentpage().getparameters().get('id');
system.debug('!!!!!'+wid);
}
public list<C_P_Widgets__c> widdata{set;get;}
public list<C_P_Widgets__c> getwiddata()
{
widdata = new list<C_P_Widgets__c>();
for(C_P_Widgets__c allwids : [select id, name, Displayed_Values__c, Widget_Category__c from C_P_Widgets__c where id=:wid limit 1])
{
widdata.add(allwids);
}
system.debug('alllll' +widdata);
return widdata;
}
}
My problem is I can't see the saved values in this page.....Don't know why?please help
try changing this public string wid{set;get;} to public string wid{get;set;}
and is it showing up in the debug logs and not in the visualforce page or not showing up at all?
Im getting only the id but no values coming into the debug log.........I think the problem is with the for loop......No values are coming into debug log when I keep in a for loop
public list<C_P_Widgets__c> getwiddata()
{
widdata = new list<C_P_Widgets__c>();
for(C_P_Widgets__c allwids : [select id, name, Displayed_Values__c, Widget_Category__c from C_P_Widgets__c where id=:wid])
{
system.debug('alllll' +wid);
widdata.add(allwids);
system.debug('alllll' +allwids);
}
system.debug('alllll' +widdata);
return widdata;
}
One more question, are you seeing the saved values in the C_P_Widgets__c record page? Maybe it's in the save function and it's not saving the values? The for loop seems to be fine, except why do you limit it to 1? Are you trying to get all C_P_Widgets__c for wid or just 1?
Hi. I believe the problem is with the get;set. You are trying to have two get methods for the variable 'widdata'.
Remove the 'get' in the line "public list<C_P_Widgets__c> widdata{set;get;}" and your code will work.