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
Arun BalaArun Bala 

Tricky problem ...

Folks,
I am developing a VF page, where I render a task list on a pageBlockTable. Now on the pageBlockTable, apart from the standard task fields, I also have a field called 'Day' that will display the english day of the activityDate (like Thu or Fri or..) .. Below is my current code:

                    <apex:pageBlockTable value="{!dataTabTasks}" var="task" cellspacing="4" id="taskTable">
                        <apex:column >
                            <apex:facet name="header">Action</apex:facet>
                               <a href="#" onclick="delTask('{!task.Id}','{!$Component.theHiddenInput}');"><b>Del</b></a>
                       </apex:column>
                        <apex:column >
                            <apex:facet name="header">Comment</apex:facet>
                            <a href="#"> <apex:image url="{!$Resource.addComment_img}" styleClass="toggleArrow toggleArrowCollapsedEmpty;" alt="Expand" title="Expand"
                              onclick="toggleFieldEdit('{!$Component.pg1}','{!$Component.pg2}');"/></a>
                       </apex:column>
                       <apex:column >                  
                            <apex:facet name="header">Task Subject</apex:facet>
                            <apex:inputfield id="subject" value="{!task.subject}" required="true" style="width: 110px;"/>
                            <apex:panelGrid columns="1" id="pg1" style="display: none;">
                                <apex:facet name="header"><b>Comments</b></apex:facet>
                                <apex:inputText id="description" value="{!task.description}" maxlength="2000" style="width: 160px; height: 40px;word-wrap: break-word "/>
                            </apex:panelGrid>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Day</apex:facet>
                            <apex:outputText id="day_id" style="width: 40px;font-weight: bold;" value="{??}"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Due Date</apex:facet>
                            <apex:inputfield id="activityDate" value="{!task.activityDate}" />        
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Assigned To</apex:facet>
                            <apex:inputfield id="ownerid" value="{!task.ownerid}" style="width: 110px;"/>
                            <apex:panelGrid columns="2" id="pg2" style="display: none;">
                                <apex:facet name="header"><b>Reminder</b></apex:facet>
                                <apex:inputfield id="reminderChkBox_id" value="{!task.IsReminderSet}"/>
                                <apex:inputfield id="reminder" value="{!task.ReminderDateTime}" style="width: 110px;"/>
                             </apex:panelGrid>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Type</apex:facet>
                            <apex:inputfield id="type" value="{!task.type}" style="width: 110px;"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Priority</apex:facet>
                            <apex:inputfield id="priority" value="{!task.priority}" required="false" style="width: 110px;"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Status</apex:facet>
                            <apex:inputfield id="status" value="{!task.status}" required="false" style="width: 110px;"/>
                        </apex:column>                   
                    </apex:pageBlockTable>

My problem is with the line highlighted in Red.<apex:outputText id="day_id" style="width: 40px;font-weight: bold;" value="{??}"/>; Now is there a way to load the 'day' of the activity based on the activityDate when the pageBlockTable is rendered.  day is not part of the standard Task Object fields and hence we need to calculate it manually. But not sure when / how / where to do this calculation.

Your help will be highly appreciated !!
SuzanyuSuzanyu
Hi Arun,
 
try
<apex:OutputText id="day_id" style="width: 40px;font-weight: bold;" value="{!CASE(MOD( task.activityDate - DATE(1900, 1, 7), 7),0, "Sun",1, "Mon",2, "Tue",3, "Wed",4, "Thu",5, "Fri",6, "Sat", "Error")}"/>
 
hope it helpful
Arun BalaArun Bala
Suzanyu ,
Fantastic hint --- this worked like a charm ...  I truly appreciate your quick help !!!


Thanks again
Arun BalaArun Bala
Hi Suzanyu,
Just a follow-up on the above issue. I would appreciate if you could shed some inputs on the below:

1. Can't the value of an outputText (in my case day_id) be changed in a javascript function like doing - document.getElementById(param1).value = ... ; I can see the new value is being set for the outputText but the same is not getting rendered on the page.

2. Also when I use the above case statment for the apex:inputText tag, I get a missing ')' error.

Any hints would be helpful,
Thanks
SuzanyuSuzanyu

1. I can not figure out the way you try to change the outputText value. Actually that can't be changed directly by calling document.getElementById(param1).value = ... . ,because the value actually is binded with system function or cotroller data.

Please tell me what you need

 

2. if you use apex:inputText tag, anything with "apex:" means there is a direct way to communicate with controller. OutputText to show the data from controller. inputText is to pass the data to corresponding variable in controller. The way I show above just for outputText. I guss you try to store the information into the record with day_id whatever. That can be done via other ways.

Please let me know details about what you are doing now

 

Arun BalaArun Bala
Hi Suzanyu,
Thanks for your response. What I am trying to do is : on change of the task activity date,  I need to display the corresponding day_id. The output text loads the day while rendering the datatable based on the formula you suggested but I am trying to update its value onchange of the activityDate using a JS.

Do you suggest any alternatives for this ?


Message Edited by Arun Bala on 12-09-2008 10:02 AM
SuzanyuSuzanyu
you got two columns. Your goal is when you change the acitivityDate, the day_id changed accordingly  with the style as I provided before. If my understanding correct,  there is a way but not javascript.
------------------------your code
<apex:column >
          <apex:facet name="header">Day</apex:facet>
          <apexutputText id="day_id" style="width: 40px;font-weight: bold;" value="{??}"/>
</apex:column>
<apex:column >
          <apex:facet name="header">Due Date</apex:facet>
          <apex:inputfield id="activityDate" value="{!task.activityDate}" />         
</apex:column>

------------------------ code below is my idea

<apex:column >
          <apex:facet name="header">Day</apex:facet>
          <apexutputText id="day_id" style="width: 40px;font-weight: bold;" value="{!CASE(MOD( task.activityDate - DATE(1900, 1, 7), 7),0, "Sun",1, "Mon",2, "Tue",3, "Wed",4, "Thu",5, "Fri",6, "Sat", "Error")}"/>
</apex:column>

<apex:column >
           <apex:facet name="header" >Due Date</apex:facet>
           <apex:inputField id="activityDate" value="{!task.activityDate}" />
                        <apex:actionSupport event="onchange"  action="{!nonAction}"  rerender="taskTable" />  // "taskTable" is your datatable Id
           </apex:inputField> 
</apex:column>
in your controller add code below
 
 public PageReference nonAction(){
          return null;
}
 
 
Any question let me know
 
good luck


Message Edited by Suzanyu on 12-09-2008 02:33 PM
Arun BalaArun Bala
This is super cool idea ... thanks Suzanyu.