• Joe B.ax302
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Ok, so here is my code.

Page:

Code:
<apex:page standardController="Task" extensions="timeTrackingExtension" tabStyle="Task">
    <apex:form >
        
        <apex:detail />
        
        <apex:Pageblock title="Time entry">
            <apex:inputText value="{!time}" id="time" />
            <apex:inputText value="{!duration}" id="duration" />
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" style="margin-top: 15px" action="{!create}" rerender="detail,ttrecords,resultPanel" status="saveStatus" />
            </apex:pageBlockButtons>
        </apex:Pageblock>

        <apex:actionStatus id="saveStatus" startText="Creating new time tracking record..." stopText="" />

        <apex:Pageblock title="Time Tracking History">
            <apex:outputPanel id="detail">
            <apex:pageBlockTable value="{!timeTrackingRecords}" var="tt" id="ttrecords">
                <apex:column value="{!tt.Name}" />
                <apex:column value="{!tt.Owner__c}" />
                <apex:column value="{!tt.Time__c}" />
                <apex:column value="{!tt.Duration__c}" />
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:Pageblock>
        
        <apex:pageBlock title="Fetched Data">
            <apex:outputPanel id="resultPanel" layout="block">
                Result: {!timeTrackingRecords}"
            </apex:outputPanel>
        </apex:pageBlock>


    </apex:form>
</apex:page>

 
Controller:

Code:
public class timeTrackingExtension {

    private final Task task;
    Integer ttime = 0;
    String duration;
    List<TimeTracking__c> timeTrackingRecords;
    
    // The extension constructor initializes the private member
    // variable task by using the getRecord method from the standard
    // controller.
    public timeTrackingExtension(ApexPages.StandardController stdController) {
        this.task = (Task)stdController.getRecord();
    }
    
    // Return TimeTracking__c records for the task specified in the query string
    // i.e.
    // —id=00TT0000008kYBKMA2
    public List<TimeTracking__c> getTimeTrackingRecords() {
        
        if(timeTrackingRecords == null) timeTrackingRecords = [Select t.Duration__c, t.Id, t.Name, t.Owner__c, t.TaskId__c, t.Time__c from TimeTracking__c t
            where t.TaskId__c = :ApexPages.currentPage().getParameters().get('id')];
        
        for(TimeTracking__c tt : timeTrackingRecords) {
            System.debug(tt.Name);
        }
        
        return timeTrackingRecords;
        
    }
    
    public Integer getTime() {
        return ttime;
    }
    
    public void setTime(Integer i) {
        ttime = i;
    }
    
    public String getDuration() {
        return duration;
    }
    
    public void setDuration(String s) {
        duration = s;
    }
    
    // Creates a TimeTracking__c record
    public PageReference create() {
        TimeTracking__c newTimeTrackingRecord = new TimeTracking__c();
        newTimeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        newTimeTrackingRecord.Owner__c = UserInfo.getUserId();
        newTimeTrackingRecord.Time__c = ttime;
        newTimeTrackingRecord.Duration__c = duration;
        insert newTimeTrackingRecord;
        return null;
    }

}

 
For some reason or another the pageBlockTable and outputPanel are not being updated after I create a new record.  Anyone have any ideas as to why?  My initial thought is that I need to do my insert differently...

Other options are welcome :)  Thanks!@
Hi all, I'm not sure if this is expected functionality:

Code:
<apex:page >
    <script type="text/javascript">
        window.onload = new function() { alert('{!$Component.pbHelloWorld}'); alert('{!$Component.txtFoo}'); };
    </script>
    <apex:pageBlock id="pbHelloWorld" title="Hello, World">
    </apex:pageBlock>
    <apex:form>
        <apex:inputText id="txtFoo" />
    </apex:form>
</apex:page>

The id for the pageBlock will return; but not the one for the inputText.  

Does anyone know why this is?

I would also like to include an inputText field in a repeater or pageBlockTable and have the id be dynamically created for each row.  Asking too much?? :-) I know that this works visually:

Code:
<apex:pageBlock>
    <apex:pageBlockTable>
        <apex:column>
            <apex:form>
                <apex:inputText id="row" />
            </apex:form>
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>

 

Thanks in advance if anyone can help.
Ok, so here is my code.

Page:

Code:
<apex:page standardController="Task" extensions="timeTrackingExtension" tabStyle="Task">
    <apex:form >
        
        <apex:detail />
        
        <apex:Pageblock title="Time entry">
            <apex:inputText value="{!time}" id="time" />
            <apex:inputText value="{!duration}" id="duration" />
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" style="margin-top: 15px" action="{!create}" rerender="detail,ttrecords,resultPanel" status="saveStatus" />
            </apex:pageBlockButtons>
        </apex:Pageblock>

        <apex:actionStatus id="saveStatus" startText="Creating new time tracking record..." stopText="" />

        <apex:Pageblock title="Time Tracking History">
            <apex:outputPanel id="detail">
            <apex:pageBlockTable value="{!timeTrackingRecords}" var="tt" id="ttrecords">
                <apex:column value="{!tt.Name}" />
                <apex:column value="{!tt.Owner__c}" />
                <apex:column value="{!tt.Time__c}" />
                <apex:column value="{!tt.Duration__c}" />
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:Pageblock>
        
        <apex:pageBlock title="Fetched Data">
            <apex:outputPanel id="resultPanel" layout="block">
                Result: {!timeTrackingRecords}"
            </apex:outputPanel>
        </apex:pageBlock>


    </apex:form>
</apex:page>

 
Controller:

Code:
public class timeTrackingExtension {

    private final Task task;
    Integer ttime = 0;
    String duration;
    List<TimeTracking__c> timeTrackingRecords;
    
    // The extension constructor initializes the private member
    // variable task by using the getRecord method from the standard
    // controller.
    public timeTrackingExtension(ApexPages.StandardController stdController) {
        this.task = (Task)stdController.getRecord();
    }
    
    // Return TimeTracking__c records for the task specified in the query string
    // i.e.
    // —id=00TT0000008kYBKMA2
    public List<TimeTracking__c> getTimeTrackingRecords() {
        
        if(timeTrackingRecords == null) timeTrackingRecords = [Select t.Duration__c, t.Id, t.Name, t.Owner__c, t.TaskId__c, t.Time__c from TimeTracking__c t
            where t.TaskId__c = :ApexPages.currentPage().getParameters().get('id')];
        
        for(TimeTracking__c tt : timeTrackingRecords) {
            System.debug(tt.Name);
        }
        
        return timeTrackingRecords;
        
    }
    
    public Integer getTime() {
        return ttime;
    }
    
    public void setTime(Integer i) {
        ttime = i;
    }
    
    public String getDuration() {
        return duration;
    }
    
    public void setDuration(String s) {
        duration = s;
    }
    
    // Creates a TimeTracking__c record
    public PageReference create() {
        TimeTracking__c newTimeTrackingRecord = new TimeTracking__c();
        newTimeTrackingRecord.TaskId__c = ApexPages.currentPage().getParameters().get('id');
        newTimeTrackingRecord.Owner__c = UserInfo.getUserId();
        newTimeTrackingRecord.Time__c = ttime;
        newTimeTrackingRecord.Duration__c = duration;
        insert newTimeTrackingRecord;
        return null;
    }

}

 
For some reason or another the pageBlockTable and outputPanel are not being updated after I create a new record.  Anyone have any ideas as to why?  My initial thought is that I need to do my insert differently...

Other options are welcome :)  Thanks!@
Hi all, I'm not sure if this is expected functionality:

Code:
<apex:page >
    <script type="text/javascript">
        window.onload = new function() { alert('{!$Component.pbHelloWorld}'); alert('{!$Component.txtFoo}'); };
    </script>
    <apex:pageBlock id="pbHelloWorld" title="Hello, World">
    </apex:pageBlock>
    <apex:form>
        <apex:inputText id="txtFoo" />
    </apex:form>
</apex:page>

The id for the pageBlock will return; but not the one for the inputText.  

Does anyone know why this is?

I would also like to include an inputText field in a repeater or pageBlockTable and have the id be dynamically created for each row.  Asking too much?? :-) I know that this works visually:

Code:
<apex:pageBlock>
    <apex:pageBlockTable>
        <apex:column>
            <apex:form>
                <apex:inputText id="row" />
            </apex:form>
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>

 

Thanks in advance if anyone can help.