Community - MyPage.ImageGallery is always null - episerver

whenever I try to get the user myPage, the ImageGallery for that myPage is always null because of which I am not able to add a potrait and update myPage. Below is my code.
Image portraitImage = new Image(null, imageName, String.Empty, author, memoryStream);
portraitImage.Status = EntityStatus.Approved;
// Update the user's my page with the new image
MyPage myPage = (MyPage)MyPageHandler.Instance.GetMyPage(commonUser).CreateWritableClone();
myPage.Portrait = portraitImage;
MyPageHandler.Instance.UpdateMyPage(myPage);
MyPageHandler.Instance.UpdateMyPage(myPage) always throws an error saying myPage.ImageGallery is null.

You do not set the ImageGallery property anywhere in your code. The only property you set is Portrait
myPage.Portrait = portraitImage;

Related

React - when document open in new tab change the name of this new tab

I need to open document in a new tab in the browser and change the name of this tab
I wrote this code:
const blobUrlDocs = URL.createObjectURL(blob);
var newWindow = window.open(blobUrlDocs, "_blank");
newWindow.document.title = data.D_NAME;
return newWindow;
but the namews tab has not changed
I try wrote it in onload function :
newWindow.onload = function () {
newWindow.document.title = data.D_NAME;
return newWindow;
};
But the name of the tab only changed when the document was loaded.
What should I do so that the name of the document remains even after loading the document?

Extjs grid.reconfigure throws Exception (Uncaught TypeError: Cannot read property 'isSorter' of null)

I'm trying to reset grid to initial state before any user's changes of column width, order, visibility and so on. I saved columnConfigs in initialConfig of grid like that
var gridColumns = grid.getColumns();
var initialColumnConfigs = [];
Ext.Array.map(gridColumns, function (column) {
initialColumnConfigs.push(column.getInitialConfig());
});
grid.getInitialConfig().initialColumnConfigs = initialColumnConfigs;
and now I'm trying to reset grid using reconfigure like that:
initialColumnConfigs = grid.getInitialConfig().initialColumnConfigs;
Ext.state.Manager.clear(grid.stateId);
grid.reconfigure(grid.getStore(), initialColumnConfigs);
but I end up with exception from title. Is there something that I'm doing wrong?

How to focus on second tab and work on it using selenium webdriver

I have opened the link now i am clicking on login link on that page,
By clicking on login button its opening in a new tab automatically. I have to fill the form in that tab. For that i tried following code:
Actions act = new Actions(Initialsetupfirefox.driver);
new Actions(Initialsetupfirefox.driver) .keyDown(Keys.CONTROL).click(Initialsetupfirefox.driver.findElement(By.xpath("//a[contains(text(),'LOGIN')]")))
.keyUp(Keys.CONTROL)
.perform();
Thread.sleep(3000);
new Actions(Initialsetupfirefox.driver).sendKeys(Initialsetupfirefox.driver.findElement(By.tagName("html")), Keys.CONTROL).sendKeys(Initialsetupfirefox.driver.findElement(By.tagName("html")),Keys.NUMPAD2).build().perform();
By this i am able to switch the focus but not able to do anything in this tab.
Please suggest
you can do like this:
Set<String> handles = driver.getWindowHandles();
String currentHandle = driver.getWindowHandle();
for (String handle : handles) {
if (!handle .equals(currentHandle))
{
driver.switchTo().window(handle);
}
}
//fill your form in the other tab
......
//go back to first tab if you want
driver.switchTo().window(currentHandle);
This it the code when using selenium with Node.js and Typescript
const mainHandle = await this.driver.getWindowHandle();
// load new tab here ..
const allHandles = await this.driver.getAllWindowHandles();
for (const handle of allHandles) {
if (handle !== mainHandle) {
await this.driver.switchTo().window(handle);
}
}
Get the browser-tabs and do as you like:
List<String> browserTabs = Lists.newArrayList(driver.getWindowHandles());
driver.switchTo().window(browserTabs.get(1)); // Switch to second tab
// Do something on second tab here...
driver.switchTo().window(browserTabs.get(0)); // Return to first tab
// Do something on first tab here...

Vaadin - How to convert a Grid column which has boolean value to Checkbox

I am using Vaadin 7.6.4 for my UI work. This has the following:-
I have a window which contains a grid with data in it. This window is actually a kind of a pop up[ which shows up when my main screen gets a click on the settings icon( not shown here). This is working fine( getting the UI screen to open the Vaadin window when the settings icon the main screen is clicked).
The problem is in showing the data as mentioned below.
This grid will have 4 columns for which the data comes from a bean container.
The first column is a boolean field with true/false getting displayed based on the data from the bean container.
I need to convert this boolean field column into a checkbox with true showing the field as a checkbox with a value selected. If the value is false, then show a checkbox which is not selected.
I am trying to do that as shown in the code below but I keep getting this checkbox name printed. I dont see the checkbox but the word "checkbox" printed in there?
This checkbox should be editable. The idea is that the user should be able to select some checkboxes and the ones selected should be shown in a panel ( not shown here). Thus, the checkbox has to be editable.
How do I fix this? The code for the window is shown below
package com.platform28.mybatis;
import java.util.List;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.data.util.GeneratedPropertyContainer;
import com.vaadin.data.util.PropertyValueGenerator;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Grid;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
#SuppressWarnings("serial")
public class ConfigPopUp extends Window {
VaadinUtils vaadinUtils = null;
public ConfigPopUp(List<TableColumnData> tblDataLst) {
vaadinUtils = new VaadinUtils();
// Some basic content for the window
VerticalLayout configLayout = new VerticalLayout();
configLayout.addComponent(new Label("Settings"));
configLayout.setMargin(true);
//configLayout.setWidth(null);;
setContent(configLayout);
//adding grid.
List<SettingsColumnData> settingsList = vaadinUtils.processSettingsList(tblDataLst);
final BeanItemContainer<SettingsColumnData> gridDataSource = new BeanItemContainer<SettingsColumnData>(SettingsColumnData.class, settingsList);
//change boolean value to checkbox.
GeneratedPropertyContainer gp = new GeneratedPropertyContainer(gridDataSource);
gp.addGeneratedProperty("columnDisplayed", new PropertyValueGenerator<CheckBox>() {
#Override
public CheckBox getValue(Item item, Object itemId, Object propertyId) {
boolean currentCheckBoxValue = (boolean) item.getItemProperty("columnDisplayed").getValue();
CheckBox chkBox = new CheckBox();
chkBox.setValue(currentCheckBoxValue);
return chkBox;
}
#Override
public Class<CheckBox> getType() {
return CheckBox.class;
}
});
Grid settingsGrid = new Grid(gp);
settingsGrid.setWidth("100%");
settingsGrid.setSizeFull();
settingsGrid.setColumnOrder("columnDisplayed", "columnName","columnShortName","columnDescription");
configLayout.addComponent(settingsGrid);
//configLayout.setExpandRatio(settingsGrid, 1);
// Disable the close button
setClosable(false);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setSpacing(true);
hLayout.setMargin(true);
// Trivial logic for closing the sub-window
Button ok = new Button("Ok");
ok.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
close(); // Close the sub-window
}
});
hLayout.addComponent(ok);
// Trivial logic for closing the sub-window
Button cancelBtn = new Button("Cancel");
cancelBtn.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
close(); // Close the sub-window
}
});
hLayout.addComponent(cancelBtn);
configLayout.addComponent(hLayout);
// set pop up to center.
center();
// should be resizable
setResizable(true);
// should not be draggable
setDraggable(false);
//set it as modal window
setModal(true);
setWidth("50%");
setHeight("75%");
}
}
Ok, we used the SelectionMode.MULTI to show the selection of rows in there.
https://cdn.vaadin.com/vaadin-core-elements/latest/vaadin-grid/demo/selection.html
Still, I would love to learn more as to how we get the change done as shown in the question above.
Still looking for an answer to that.
Use a Renderer and a Converter, you don't need to use SelectionMode.MULTI.
An example of this is posted here.

Removing border from TextArea in CodenameOne causes the component to stop growing to fit text

I want to implement a TextArea in CodenameOne as follows:
private Container getMessageContainer(String message) {
Container con = new Container(new BorderLayout());
TextArea ta = new TextArea();
ta.setGrowByContent(true);
ta.setSingleLineTextArea(false);
ta.setScrollVisible(true);
ta.setUIID("DialogTextArea");
ta.setEditable(false);
ta.setFocusable(false);
ta.setText(message);
con.addComponent(BorderLayout.CENTER, ta);
return con;
}
I then have a Theme Component in the theme.res file called DialogTextArea deriving TextArea, as follows:
This TextArea is then put on a Dialog as follows:
public MessageDialog(NotificationType notificationType, String title, String message,
boolean fallback) {
this.notificationType = notificationType;
this.fallback = fallback;
this.buildTitle(title);
this.setLayout(new BorderLayout());
this.addComponent(BorderLayout.CENTER, getContentConainer(message));
this.addComponent(BorderLayout.SOUTH, getButtonContainer());
}
private Container getContentConainer(String message) {
Container con = new Container(new BorderLayout());
con.addComponent(BorderLayout.CENTER, getMessageContainer(message));
return con;
}
Where MessageDialog extends Dialog.
This does work well, and I get the following results:
And:
However, when I remove the border from the theme in the theme.res, turning it into an Empty border, I get this as a result:
As well as
This does mean there are some inconsistencies when I wish to remove the border.
Is there any way to get the text to always display when I do not want a border? I tried changing the padding and margin properties, but to no avail.
This is all using the Native theme.
Any help would be appreciated.
private Container getMessageContainer(String message) {
Container con = new Container(new BorderLayout());
TextArea ta = new TextArea();
ta.setGrowByContent(true);
ta.setSingleLineTextArea(false);
ta.setScrollVisible(true);
ta.setUIID("DialogTextArea");
ta.setEditable(false);
ta.setFocusable(false);
ta.setText(message);
con.addComponent(BorderLayout.CENTER, ta);
Label transparentLabel = new Label("");
transparentLabel.getAllStyle().setBgColor(0xffffffff);
con.addComponent(BorderLayout.SOUTH, transparentLabel);
return con;
}
This gives a temporary solution.
You need to remove the border from the selected, unselected states as well as the padding from both. If you don't do that we will pick the "most" option and go with that to prevent "jumping" on every focus change.
Note that selected state is still applicable even if you selected the component to not have focus or editability.

Resources