function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NajoopNajoop 

conditionally Displaying VF output panel and passing parameter to controller from markup.

Hi,

 

I am trying to code my first VF page and am stuck. gone through documentations and guides and community.

if anyone can help with this , would appreciate.

 

I am trying to show a pageblock based on the results of first query results. Searching for accounts. when clicked on account Name, show details about the cases in another panel.

 

I know I am doing something wrong but dont know what.

 

here is my code

markup

 

<apex:page controller="Mycontroller" >
<apex:form >
    <apex:pageBlock id="block">
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
            <apex:outputLabel for="searchText">Search Account</apex:outputLabel>
                <apex:panelGroup >
                <apex:inputText id="searchText" value="{!searchText}"/>
                <apex:commandButton value="Go!" action="{!doSearch}" rerender="block" status="status"/>
                </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="Processing..."/>
        <apex:pageBlockSection title="Account Detail Results" id="results" columns="2">
        <apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}">
               <apex:actionSupport event="ondblClick" action="{!getScore}" reRender="Score">
               <apex:param name="aid" value="{!l.Name}"/>
               </apex:actionSupport>
             <apex:column value="{!l.Name}"/>
             <apex:column value="{!l.Account_Type__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlockSection>
        </apex:pageblock>
        </apex:form>               
        <apex:outputPanel id="Score" rendered="true" >
        <apex:pageblock>
        <apex:pageBlockSection title="Score Card"  id="results" columns="4" rendered = "True">
        <apex:pageBlockTable value="{!Score}" var="S" rendered="{!NOT(ISNULL(Score))}">
            <apex:column value="{!S.Account.Name}"/>
            <apex:column value="{!S.casenumber}"/>
            <apex:column value="{!S.Solution_Type__c}"/>
            <apex:column value="{!S.ClosedDate}"/>
        </apex:pageBlockTable >
        </apex:pageBlockSection >
        </apex:pageBlock>
        </apex:outputPanel>
</apex:page>

 

Controller

 

Public class Mycontroller {
       
    String searchText;
    List<Account> results;
    List<Case> Score;
       
    Public string getSearchtext(){
        return searchText;
        }
       
    Public void setSearchText (String s) {
        searchtext = s;
        }
    
           
    Public List<Account> getResults() {
        return results;
        }
   
    Public List<Case> getScore() {
        Score = [select Account.Name, casenumber, Solution_Type__C, ClosedDate from case where Account.Name = :searchText and status = 'Closed' limit 10];
        return Score;
        }
       
    Public PageReference doSearch () {
        results = (List<Account>) [FIND :searchtext RETURNING Account(ID, Name, Account_type__C)][0];
        return null;
        }
  }

 

I also wanted to move away from :searchtext and pass aid from markup to this query, not sure how to do it.

 

I also tried this rendered function but did not appear to resolve what I am trying to do.

 

 Public boolean getRendered() {
        Boolean render = (Score == null || results.size() == 0 );
        return render;
        }

 

 

any help anyone can provide is appreciated. been on this for last 3 days.

 

thanks a lot

Poojan.

wesnoltewesnolte

Hey

 

Is any of your code working i.e. is the button that calls doSearch returning any results? What is not working? Is is the detail panel?

 

Cheers,

Wes

NajoopNajoop

Yes, doSearch returns correct results.

Also, since last time I added commandlink to the AccountName field to pick up the value for the case records.

 

getRendered method is somewhat working now (it displays the CScore panel the first time when loaded but when you refresh without any search it dissapears).

 

Another issue is when getScore is only getting specific account case records, it seems that last record in search results.

zeezackisbackzeezackisback

Yes I have a similar problem and I am stuck too.

 

I have created a visual force page that will break down the case in my situation, claims. 

 

I need a special tab/section will display particular editiable fields only when particular conditions have been met on the status of the claim.

 

please help.

 

 

 

<apex:page standardController="Claim__c" showHeader="true" tabStyle="Claim__c" > <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:tabPanel switchType="client" selectedTab="tabdetails" id="ClaimTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Details" name="AccDetails" id="tabdetails"> <apex:detail relatedList="false" title="true"/> </apex:tab> <apex:tab label="I am special thing" name="I am special thing" id="tabSpecThin"> <apex:page standardController="Claim__c"> <apex:form > <apex:pageBlock title="Hello {!$User.FirstName}!"> You are viewing the {!Claim__c.name} account. <p/> You are viewing the {!Claim__c.Claim_Status__c} account. <p/> if(!Claim__c.Claim_Status__c='Agreement Illegible') { <apex:outputText value="The unformatted time right now is: {!NOW()}" /> } <script> var char =9; if(char==9) { document.write("Change Account Name: <apex:inputField value="{!Claim__c.name}"/> <br/>"); } </script> Change Status: <apex:inputField value="{!Claim__c.Claim_Status__c}"/> <br/> <apex:commandButton action="{!save}" value="Save New Account Name"/> </apex:pageBlock> </apex:form> </apex:page> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct"> <apex:relatedList subject="{!Claim__c}" list="OpenActivities" /> </apex:tab> <apex:tab label="Activity History" name="ActivityHistory" id="tabAH"> <apex:relatedList subject="{!Claim__c}" list="ActivityHistories" /> </apex:tab> <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt"> <apex:relatedList subject="{!Claim__c}" list="NotesAndAttachments" /> </apex:tab> </apex:tabPanel> </apex:page>

 

 

 

NajoopNajoop

With the formula fields I was able to get it worked  rendered="{!score.Size > 0}" . i guess we can put in conditions which returns boolean type to dynamically display a panel or pageblock Or we can add a function for condition evaluation in controller that returns boolean and use that boolean as the rendered value.

 

 

<apex:pageBlock id="block">
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
            <apex:outputLabel for="searchText">Search Account</apex:outputLabel>
                <apex:panelGroup >
                <apex:inputText id="searchText" value="{!searchText}"/>
                <apex:commandButton value="Go!" action="{!doSearch}" rerender="block" status="status"/>
                </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="Processing..." onstop="No records found"/>
        <apex:pageBlockSection title="Account Search Results" id="results" columns="3" >
        <apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}">
             <apex:column >
               <apex:Facet name="header">Account Name</apex:Facet>
               <apex:actionSupport event="onmouseover" action="{!getScore}" reRender="CScore" status="CScoreStatus">
               </apex:actionSupport>
               <apex:commandLink action="{!SetAccount}" value="{!l.Name}">
               <apex:param name="aid" value="{!l.Name}" />
               </apex:commandLink>
             </apex:column>
             <apex:column value="{!l.Account_Type__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlockSection>
        </apex:pageblock>
        <apex:outputPanel id="CScore" rendered="{!score.Size > 0}" >
        <apex:pageblock >
        <apex:pageBlockSection title="Score Card"  id="results" columns="4" rendered="True">
        <apex:pageBlockTable value="{!Score}" var="S" rendered="{!NOT(ISNULL(Score))}">
            <apex:column value="{!S.Account.Name}"/>
            <apex:column value="{!S.casenumber}"/>
            <apex:column value="{!S.Solution_Type__c}"/>
            <apex:column value="{!S.ClosedDate}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
        </apex:pageBlock>
        </apex:outputPanel>
     </apex:form>
</apex:page>

Message Edited by Najoop on 07-14-2009 03:37 AM