• Alex Sasha
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies

For instance I have some object  let's say "territory" which is look up fro user object

When I'm creating different territories and assigning them one particular  user let's say "user 1"

How Can I then  see related list of territories on this user?

 

I would like to know are any ways to save my current page state when refreshing this page

In my particular  case i have bucket which refreshing every time when add new product to it via rerendered attribute. I would like to save this bucket state when page will be refreshed

User-added image

When I'm using PageReference class to reference to another page it seems like on referenced page viewstate remains 

Public PageReference backToPage(){

        return new PageReference('/apex/gindex');
    }
so gindex page  has it previouse  viewstate remaind

Is any ways to reference it and reload it fully;


in my pages i have several links to another visualforce pages in developer edition I used hard coded links such like this:
<apex:outputLink value="https://c.eu6.visual.force.com/apex/gindex" id="theLink">Back to shop</apex:outputLink>

On controller side
Public PageReference backToPage(){

            return new PageReference('/apex/gindex');
        }

How to set them properly in force.com site?

I' m passing parametrs ro controller from 2 palaces 
first look like:

<apex:dataTable id="tableCategories"  value="{!products}" var="prod" styleClass="table table-striped">      
.......
   <apex:column >
                        <apex:form >

                        <apex:commandButton action="{!makevisibleProduct}" value="View details" 
                         styleClass="btn-success">                
                                     <apex:param name="product" value="{!prod.name}"/>
                         </apex:commandButton>

                        </apex:form>

      </apex:column>
 


                     
controller:

public  with sharing class HomeController {
    private String  ProdName;
  public PageReference makevisibleProduct(){
          productVisibility=true;
            ProdName = ApexPages.currentPage().getParameters().get('product');
          return null;
    }
 public Boolean getisVisibleProduct(){
    
        return productVisibility;
    }
 


Then I want to render particualr product detail with name= Prodname;

Public Product__c getProduct(){
       
        List<Product__c> products =[Select name, description__c, quantity__c,price__c from Product__c
                                   WHERE name =: ProdName
                                   ];
        return products[0];
    }

Table that should displays products:

<apex:pageBlock id ="tableProduct" rendered="{!isVisibleProduct}" mode="maindetail">

                <vs:panel title="Demo Panel Primary" type="primary">
                    <table class="table table-condensed" >
                   
                    <tr>
                      <td class="active">{!product.name} </td>
                    </tr>
....

Whe clicking the button output is:

Visualforce Error
Help for this Page
System.ListException: List index out of bounds: 0 
Class.HomeController.getProduct: line 57, column 1

this line: 

return products[0];

But strangely thing that a has nearly the same button in another place of code which works fine:
 

      <apex:form >
                    <apex:repeat value="{!categories}" var="cat" id="theRepeat">

                        <apex:commandButton reRender="tableCategories" style="margin:4px" value="{!cat.name}"               styleClass="btn-success">

                            <apex:param name="category" value="{!cat.name}"/>
                            </apex:commandButton>

                    </apex:repeat>
         </apex:form>


 

<apex:dataTable id="tableCategories"  value="{!products}" var="prod" styleClass="table table-striped">
                    <apex:facet name="header">Products</apex:facet>
                    <apex:column value="{!prod.Category__r.name}" headerValue="Category name"/>
                    <apex:column value="{!prod.name}" headerValue="Product name"/>
.....
 


controller side
 

public List<Product__c> getProducts(){
        String CategoryName = ApexPages.currentPage().getParameters().get('category');

            List<Category__c> categs = [SELECT(select id, name, Category__r.name,Maker__r.name, description__c from product__r) from Category__c WHERE name = :CategoryName];
...
            products = categs[0].product__r;
            return products;
 

 

I would like to know are any ways to save my current page state when refreshing this page

In my particular  case i have bucket which refreshing every time when add new product to it via rerendered attribute. I would like to save this bucket state when page will be refreshed

User-added image

When I'm using PageReference class to reference to another page it seems like on referenced page viewstate remains 

Public PageReference backToPage(){

        return new PageReference('/apex/gindex');
    }
so gindex page  has it previouse  viewstate remaind

Is any ways to reference it and reload it fully;


in my pages i have several links to another visualforce pages in developer edition I used hard coded links such like this:
<apex:outputLink value="https://c.eu6.visual.force.com/apex/gindex" id="theLink">Back to shop</apex:outputLink>

On controller side
Public PageReference backToPage(){

            return new PageReference('/apex/gindex');
        }

How to set them properly in force.com site?

I' m passing parametrs ro controller from 2 palaces 
first look like:

<apex:dataTable id="tableCategories"  value="{!products}" var="prod" styleClass="table table-striped">      
.......
   <apex:column >
                        <apex:form >

                        <apex:commandButton action="{!makevisibleProduct}" value="View details" 
                         styleClass="btn-success">                
                                     <apex:param name="product" value="{!prod.name}"/>
                         </apex:commandButton>

                        </apex:form>

      </apex:column>
 


                     
controller:

public  with sharing class HomeController {
    private String  ProdName;
  public PageReference makevisibleProduct(){
          productVisibility=true;
            ProdName = ApexPages.currentPage().getParameters().get('product');
          return null;
    }
 public Boolean getisVisibleProduct(){
    
        return productVisibility;
    }
 


Then I want to render particualr product detail with name= Prodname;

Public Product__c getProduct(){
       
        List<Product__c> products =[Select name, description__c, quantity__c,price__c from Product__c
                                   WHERE name =: ProdName
                                   ];
        return products[0];
    }

Table that should displays products:

<apex:pageBlock id ="tableProduct" rendered="{!isVisibleProduct}" mode="maindetail">

                <vs:panel title="Demo Panel Primary" type="primary">
                    <table class="table table-condensed" >
                   
                    <tr>
                      <td class="active">{!product.name} </td>
                    </tr>
....

Whe clicking the button output is:

Visualforce Error
Help for this Page
System.ListException: List index out of bounds: 0 
Class.HomeController.getProduct: line 57, column 1

this line: 

return products[0];

But strangely thing that a has nearly the same button in another place of code which works fine:
 

      <apex:form >
                    <apex:repeat value="{!categories}" var="cat" id="theRepeat">

                        <apex:commandButton reRender="tableCategories" style="margin:4px" value="{!cat.name}"               styleClass="btn-success">

                            <apex:param name="category" value="{!cat.name}"/>
                            </apex:commandButton>

                    </apex:repeat>
         </apex:form>


 

<apex:dataTable id="tableCategories"  value="{!products}" var="prod" styleClass="table table-striped">
                    <apex:facet name="header">Products</apex:facet>
                    <apex:column value="{!prod.Category__r.name}" headerValue="Category name"/>
                    <apex:column value="{!prod.name}" headerValue="Product name"/>
.....
 


controller side
 

public List<Product__c> getProducts(){
        String CategoryName = ApexPages.currentPage().getParameters().get('category');

            List<Category__c> categs = [SELECT(select id, name, Category__r.name,Maker__r.name, description__c from product__r) from Category__c WHERE name = :CategoryName];
...
            products = categs[0].product__r;
            return products;