如何使用SAP CRM WebClient UI實現一個類似新浪微博的字數統計器
In the blog we talk about the social media integration into CRM Interaction center agent inbox, which allows end users to directly reply facebook posts & tweets in CRM system. In order to achieve this we implement a very simple character counter which has similar functionality as that in twitter website:
The counter described in this blog is delivered by SAP in CRM 7.0 EHP3. You can find it in UI component SMCOV, view ReplyMessageView.htm. Its function is slightly different from twitter: it does not display the left number of characters which is allowed to input, but the number of characters which are ALREADY typed by end user.
The following functionalities are supported by this simple counter:
(1) Whenever you add, delete or change your input in text area, the number of characters you have typed will be automatically updated below the text area
(2) The cut & paste event are also captured by the counter Any other advanced functionalities like url automatically highlighted as hyperlink is not supported by this simple counter.
Here below is the implementation of this counter:
(1) In your UI component view, draw the visual area of the counter which will show the text “The number of characters entered:XXX” via html p tag:
<p id="COUNTER_TXT" style="margin-left: 8px; margin-top: 1px; margin-bottom: 4px; margin-right: 8px; color:rgb(102,102,102)"></p>
(2) in line 32, the function handleClick acts as the event handler which will be called automatically whenever the content in the text area is changed. In line 34 the final text in the visual area of the counter is populated.
For translation purpose, the text is not hard-coded but stored and got in Online Text Repository:
lv_title_prefix = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_SOC_SMC/COUNTER_TXT' ). "#EC NOTEXT.
lv_title_prefix = lv_title_prefix && ':'.
In line 35 the current number of characters is updated in the visual area of the counter. The variable counter is a DOM variable which represents the html tag p with ID COUNTER_TXT, which is retrieved later.
The function fillTitle is designed to ensure the counter still displays the correct number of typed characters in text area when the UI is rendered for the first time ( at that time no event for the text area will be fired ). Here the biggest challenge is how to get the ID of the text area, so that we can use document.getElementByID to get its DOM node and then get the actual content which has been typed in the text area.
As this text area is not manually created via native HTML code, it is impossible to get its ID directly in the view.
However, we could investigate on the naming convention of this ID via development tool ( just click F12 on web page) of IE. Click Find->Select element by click, then click on the text area, and development tool will automatically locate the native html textarea element, and then we can observe that the naming convention for it is _socialpost_struct.content.
The current component id is available in the attribute component id of view controller, so finally we can populate the ID of text area via the following code:
(3) The left code is very easy to understand: retrieve the DOM node for input textarea ( line 47) and visual area of counter( line 48), and register the event handler for three events on text area element.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2712836/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP CRM WebClient UI 支援的一些 url 引數WebclientUI
- 自己實現一個SAP WebClient UI Repository Information SystemWebclientUIORM
- SAP CRM WebClient UI cross component跳轉的一個具體例子WebclientUIROS
- 使用Selenium自動化測試SAP CRM WebClient UIWebclientUI
- SAP CRM WebClient UI和Hybris的controller是如何被呼叫的WebclientUIController
- 如何在SAP WebClient UI裡使用jChartFXWebclientUI
- 如何把SAP CRM WebClient UI上某個欄位高亮加粗顯示WebclientUI
- SAP CRM WebClient UI和Fiori UI混搭並存WebclientUI
- Python實現微博爬蟲,爬取新浪微博Python爬蟲
- SAP WebClient UI One Hit Navigation的實現方法WebclientUINavigation
- 在SAP WebClient UI裡顯示倒數計時的UIWebclientUI
- SAP CRM WebClient UI和Hybris backoffice UI開發的相同點WebclientUI
- 如何在CRM WebClient UI裡使用HANA Live ReportWebclientUI
- SAP CRM WebClient UI異常的持久化機制WebclientUI持久化
- 將SAP CRM WebClient UI的表格匯出成PDFWebclientUI
- 如何在SAP WebClient UI裡使用HANA Live reportWebclientUI
- SAP CRM WebClient UI的Delta處理機制介紹WebclientUI
- SAP CRM WebClient UI html 格式的 Text 顯示邏輯WebclientUIHTML
- 在SAP CRM WebClient UI中用javascript觸發ABAP eventWebclientUIJavaScript
- 如何實現一個基本的微信文章分類器
- SAP CRM WebClient UI的on_new_focus應該怎麼理解WebclientUI
- SAP CRM WebClient UI表格編輯模式的除錯明細WebclientUI模式除錯
- SAP CRM WebClient UI和Hybris Commerce的懶載入機制WebclientUI
- SAP CRM WebClient UI Text Type 顯示的過濾邏輯WebclientUI
- ABAP Webdynpro和CRM WebClient UI不同的UI表現機制WebclientUI
- 使用note++開發SAP WebClient UIWebclientUI
- 如何建立一個新浪微博應用以及獲得Access token
- 在SAP CRM WebClient UI裡開啟ABAP Webdynpro頁面WebclientUI
- SAP CRM WebClient UI和ABAP Webdynpro頁面的互相跳轉WebclientUI
- SAP CRM WebClient UI Text 可編輯與否的控制邏輯WebclientUI
- Blazor如何實現類似於微信的Tab切換?Blazor
- Hybris service layer和SAP CRM WebClient UI架構的橫向比較WebclientUI架構
- SAP CRM WebClient UI,如何快速定位到丟擲錯誤訊息的那一行程式碼WebclientUI行程
- 如何將SAP WebClient UI的表格匯出成PDFWebclientUI
- 引起SAP WebClient UI頁面出現超時(time out)錯誤的另一個原因WebclientUI
- SAP CRM WebClient UI上以html格式顯示note的問題討論WebclientUIHTML
- Scrapy框架的使用之Scrapy爬取新浪微博框架
- SAP WebClient UI的白屏問題分析WebclientUI