Sitecore 8, MVC, Experience Editor: How to make a rendering refresh after a Field Editor Button has been used - sitecore

We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)
We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)
When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.
When the editor presses the ok-button (4) the values are set.
Now to the problem:
The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.
How do we achieve that?
(I am in contacts with Sitecore support but so far I have not gotten any answers...)
Update
After a lot of conversation with the support we still have no useful solution.
We tried turning it into a field renderer displaying the links.
What worked was:
The field do get updated when you have edited it in the popup field editor. (but...)
It looks good the first time when page is loaded.
You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)
What didn't work was:
The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)
The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.
We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.
Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.

This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....
This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.
Example:
User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter)
User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window.
Once the popup closes, the parent window now displays the information that the popup/editor just updated.
This takes some client side javascript (jquery) development but it is quite do-able normally.

Related

Updating CPropertyPage on tab selection

I am looking for the best way to update a CPropertyPage once it is clicked. Currently, my pages receive it's information during OnInitDialog(). However, when the user does something on page one, it can effect what is on page two.
The only solution I can think to use is an "Update" button. Once the button is clicked, the page refreshes its information by calling the same functions that take place during OnInitDialog(). Is there an event that occurs when the user clicks on a different CPropertyPage of a CPropertySheet?
Using an "Update" button is poor design because it requires the user to force the update. Instead, you should look to maintain the state of the values that could cause the update. This can be done in a structure or class object that can then be made accessible to CPropertyPage::OnSetActive of the page that needs the updated values. OnSetActive is called just before the page is to be made the active one. It's your opportunity to update values on the page before it displays.

how to set the rights for placeholder ribbon

beginner question for sitecore about settings the right.
So I have an item is open in the page editor.
The renderings on the page has bunch of icons on the ribbon. One of them called 'select the parent element (element name)'.
In my case when I click on it, I am presented with the placeholder with button 'add here' and the ribbon with some component buttons that a user can use to add the controls.
So, QUESTION:
"how I add access to the button on that ribbon for certain role? Where do I set it up? "
For some certain role that placeholder's ribbon is completely empty, including there is no button 'select the parent element' even though
i know there is a parent element.
thank you very much for help,
HF
Here are the screenshots (no icons on the placeholder ribbon, and the user's rights:
enter image description here
And here is how that looks for the admin:
All the settings for the Page Editor are held in the Core database. So in the Sitecore Desktop, switch to the core database and open up the Content Editor.
Navigate to : /sitecore/content/Applications/WebEdit
This item holds the items that make up the page editor. To edit the ribbon menues, go to:
/sitecore/content/Applications/WebEdit/Ribbons
I don't remember seeing that particular button in the Core database, so this is likely a built-in feature that requires the user to have one of the built-in permissions.
The first thing I would check is that Designing is turned on. Have the user go to the 'View' tab in Page Editor and make sure they have checked the 'Designing' checkbox.
If that doesn't work, it sounds like the user you have does not have design access to the page. I would examine the inherited roles using the User Manager and check if they have the Sitecore Designer role inherited.
It is possible they just need to be provided the correct role in the system so that they can access the buttons.
Have you tried the "Sitecore Client developing role"?
Also, for the blue arrow drop list location, in order for the rendering button to show up in that location, you have to check whether the button in the webedit folder under core database(/sitecore/content/Applications/WebEdit/Default Rendering Buttons). The Type field needs to be "Common" in order to show up in the blue arrow droplist.
Example can be the "Edit related item" (/sitecore/content/Applications/WebEdit/Default Rendering Buttons/Edit related item) shows up in the blue arrow droplist.

property sheet data validation

When the user clicks the OK or APPLY button on a property sheet and the program determines data on some page is invalid, how can I cause the page containing the error to be displayed along with a message box describing the error?
Currently the procedure doing the validation does the following while processing the PSN_APPLY notification.
MessageBox (hDlg, "Data must be positive!", "Error", MB_OK);
SetWindowLong (hDlg, DWL_MSGRESULT, PSNRET_INVALID);
This works ok if the page doing the validation (A) is currently displayed but if some other page (B) is being displayed, the message box appears with that page (B) being displayed, then when the message box is answered, the page with the validation error (A) is displayed. I thought about setting some flag so that when that page (A) gets the PSN_SETACTIVE notification it displays the message box but that seems kind of hokey.
Win32 API in c++, no MFC, no NET, nothing fancy.
I think the problem is in the design of your validation and it's presentation.
Am I right in thinking that you iterate through your property sheets, validate them and display a message box if something is awry? Because of course, what you have witnessed will happen, if I am on property page 3 and I wrote crap in to a field on property page 1.
The easiest solution is, when validating, note which property page the field in question is, and set that one active if the user has written crap in to one of your fields. This seems the fastest way possible.
Also, rather than spring up an annoying message box, reserve some room beneath the property pages to display a textual (red or otherwise) warning as to why, and then change to the appropriate property page, and highlight the offending control. Your validation routine can do this nice and easily as it loops through.
Even better, don't stop at the first error. One thing I HATE is correcting one field that I think is the only issue, only to be told every time I hit "OK" or "SUBMIT" that there's something else I missed.
I seriously think you should consider going the extra mile here... loop through ALL controls, and add all invalid ones to a list. Then change each offending control's background colour, tab colour etc... Then the user can work through and correct, no matter how many errors he or she made.

How do I reset MS Word toolbar button state on new document

I have a request from a User Group to implement the following:
Introduce a set of templates that
have some Hidden Text on the page as
instructions
Display the Hidden
Text the first time a document is
created using the templates
Introduce a custom button to toggle
the Hidden Text display
1) The templates are now created. Manual toggle of Hidden Text works.
2) should be dealt with using Auto_New to set the state of Hidden Text
3) is causing me grief. I have the code that toggles the Hidden Text and the State of the custom button when I am in the templates and the Auto New code is fine when I am in the templates covered in 1), however the state of the button also needs to be reset when I am in other templates.
What I need is something to set the status of the button depending on the Hidden Text setting whenever any document is created.
Any ideas?
I've created a macro under Normal that sets the button according to the status of HiddenText.
Not exactly what I want, in that the button may be in the wrong position when changing window views, but it's good enough...

Win32API: How to determine if EN_CHANGE was because of user action, not software action?

I find this situation comes up from time to time, and I never seem to have a really robust generic solution to it.
I have a control - in this example an EDIT control on a dialog. I want to take certain actions in response to the user - and only the user - modifying the contents of the edit control.
The edit control can be set programmatically - e.g. when the dialog is being setup, there may be an initial value placed into the edit field. Or when the user selects an item from a listview, that selection's text may well be what's placed into the edit field.
But when the user modifies the contents of the edit field, I need to know that, and respond (in this scenario, I want to clear the selection from the corresponding listview).
I am currently looking at what control has focus, and only considering EN_CHANGE's to be "from the user" if the edit control has focus.
This works beautifully under Windows 7. This fails under XP (I haven't tested Vista yet).
In XP, if the edit field has the focus, but the user clicks on the list view, and the list view tells the edit control to set its contents, then I get a notification from the edit control which claims to still have focus (::GetFocus() == HWND of edit control). But this incorrect state doesn't occur in Win7.
This is a layered interface, so I cannot modify the list-view notification handler. It gets a selection change, and updates the edit field without my involvement or ability to really intervene other than to get notifications from both of them.
Any thoughts on how to generically, permanently solve the "Is this control notification really from the user" conundrum?
You can always track LVM_ITEMCHANGING, LVM_ITEMCHANGED, and EN_MSGFILTER messages. If the edit box is modified between LVM_ITEMCHANGING and LVM_ITEMCHANGED without an EN_MSGFILTER in between then you can probably assume the user did not modify the item. Or just check to see if there are any items selected when EN_CHANGE fires and if not or the text doesn't match the selected item, assume it is a user edit.
Or use ES_MULTILINE (from EN_CHANGE documentation):
The EN_CHANGE notification is not sent
when the ES_MULTILINE style is used
and the text is sent through
WM_SETTEXT.
I'd suggest using the right message. EN_CHANGE is too generic, you want to know if the user typed or pasted text. So why not subclass the control and watch for WM_KEYPRESS messages?
Alternatively, you can set a flag in your other code that sets the edit control content. You might be able to assume that anything that makes your wndproc re-entrant represents a programmatic change.
You aren't looking for something actually secure, are you? If you just want to exclude set content calls that's fairly straightforward. If you want to differentiate between user action and programmatic simulation of user keypresses, that's a much harder problem.