As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Is it possible to publish a Page by using Tom.net API in SDL Tridion 2011?
As Nuno mentioned, use PublishEngine.Publish and refer the syntax and example
Syntax:
PublishEngine.Publish(
new IdentifiableObject[] { linkedComponent },
engine.PublishingContext.PublishInstruction,
new List() { engine.PublishingContext.PublicationTarget });
Do something like this:-
private void Publish(IdentifiableObject item, PublicationTarget publicationTarget, bool rollBackOnFailure, bool includeComponentLinks)
{
IEnumerable<IdentifiableObject> items = new List<IdentifiableObject>() { item };
IEnumerable<PublicationTarget> targets = new List<PublicationTarget>() { publicationTarget };
PublishInstruction instruction = new PublishInstruction(item.Session)
{
DeployAt = DateTime.Now,
RenderInstruction = new RenderInstruction(item.Session)
{
RenderMode = RenderMode.Publish
},
ResolveInstruction = new ResolveInstruction(item.Session)
{
IncludeComponentLinks = includeComponentLinks
},
RollbackOnFailure = rollBackOnFailure,
StartAt = DateTime.MinValue
};
PublishEngine.Publish(items, instruction, targets);
}
**Contents is copied from How to Publish Stuff Programmatically blog
Use PublishEngine.Publish, follow Intellisense from there. You'll need to provide Render and Resolve instructions, as well as the usual details like Target, start date/time, etc.
The documentation has samples, various blogs have samples, and Visual Studio should help you find what you need.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I want to migrate all alfresco repository contents from one repository to other. but i don't want the existing folder structure.
while migrating i have to validate the content according to some business requirement, and based on content type i have to create different folder structure in new repository.
Does any one did this previously.
Please help.
Thanks in Advance...
Ok, the solution that i give is not the best one, but i think it will work, we will start with a simple document and see if it's working (we will modifie the answer)
Getting the inputStram of a document
I think it's the most important part
public InputStream getTheInputStream () {
Document newDocument = (Document) getSession(serverURL, userName, password).getObject(path);
ContentStream cs = newDocument.getContentStream(null);
return cs.getStream();
}
Moving the inputStram from Server A to Server B
public void transfert() throws FileNotFoundException, IOException {
Session sessionB = getSession(serverUrlB, usernameB, passwordB);
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
Folder root = sessionB.getRootFolder();
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
File newfile = new File(fileName);
String nom = fileName;
Map<String, Object> properties = new HashMap<>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
properties.put(PropertyIds.NAME, nom);
List<Ace> addAces = new LinkedList<>();
List<Ace> removeAces = new LinkedList<>();
List<Policy> policies = new LinkedList<>();
String extension = FilenameUtils.getExtension(nom);
ContentStream contentStream = new ContentStreamImpl("content." + extension, BigInteger.valueOf(nom).length()),
new MimetypesFileTypeMap().getContentType(newfile), (theInputStream);
Document dc = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, sessionB.getDefaultContext());
}
Try this method and tell me if it's working, if you don't have the getSession method just look to this post get session method.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to generate an UI where someone can navigate through the path of a tree structure. Here is an example of what I want, taken from JavaFX Scene Builder.
Depending on the actual position in an TreeView, this UI is updated. By clicking on individual items the tree is updated.
My question:
What Nodes/Controls are best used for this approach? (no full code required. Just mention the name of the controls).
My first idea is to generate a row of buttons closely to each other, but maybe there are better ideas.
Thanks.
You can use ControlsFx's BreadCrumbBar
Pane root = ...
Label selectedCrumbLbl = new Label();
BreadCrumbBar<String> sampleBreadCrumbBar = new BreadCrumbBar<>();
root.getChildren().addAll(sampleBreadCrumbBar, selectedCrumbLbl);
TreeItem<String> model = BreadCrumbBar.buildTreeModel("Hello", "World", "This", "is", "cool");
sampleBreadCrumbBar.setSelectedCrumb(model);
sampleBreadCrumbBar.setOnCrumbAction(new EventHandler<BreadCrumbBar.BreadCrumbActionEvent<String>>() {
#Override public void handle(BreadCrumbActionEvent<String> bae) {
selectedCrumbLbl.setText("You just clicked on '" + bae.getSelectedCrumb() + "'!");
}
});
https://github.com/controlsfx/controlsfx/blob/master/controlsfx-samples/src/main/java/org/controlsfx/samples/button/HelloBreadCrumbBar.java
The chosen solution did not work for me. I had to listen to the selectedCrumbProperty.
TreeItem<String> helloView = new TreeItem("Hello");
TreeItem<String> worldView = new TreeItem("World");
hellowView.getChildren().add(worldView);
TreeItem<String> thisView = new TreeItem("This");
worldView.getChildren().add(thisView);
TreeItem<String> isView = new TreeItem("is");
thisView.getChildren().add(isView);
BreadCrumbBar<String> sampleBreadCrumbBar = new BreadCrumbBar<>(helloView);
sampleBreadCrumbBar.setSelectedCrumb(helloView);
sampleBreadCrumbBar.selectedCrumbProperty().addListener((observable, oldValue, newValue) -> {
System.out.println(newValue);
if (newValue == worldView) {
//load this view
}
});
I typed this directly into the answer. There may be errors. Leave a note.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
In my web application users need to chose folder with special file. But they don't see paths on server. How can I open server folders for viewing?
On local machine i look all directories fine:
On server like this:
call the TreeADirectory with a valid server path and you will have you tree rendered :)
private void TreeADirectory(TreeView treeView, string pathToList)
{
treeView.Nodes.Clear();
var rootInfo = new DirectoryInfo(pathToList);
var node = CreateDirNodes(rootInfo);
treeView.Nodes.Add(node);
}
private static TreeNode CreateDirNodes(DirectoryInfo directoryInfo)
{
var directoryNode = new TreeNode(directoryInfo.Name);
var dirs = directoryInfo.GetDirectories()
foreach (var directory in dirs)
{
directoryNode.Nodes.Add(CreateDirectoryNode(directory));
}
//only if you need to show files
var files = directoryInfo.GetFiles()
foreach (var file in files )
{
directoryNode.Nodes.Add(new TreeNode(file.Name));
}
return directoryNode;
}
I am developing Quiz project. In DetailsView I want to display the Question and answers.
The number of answers vary for question to question.Say example
1 ) C# Support
(i) Generics
(ii) LINQ
(iii)EntLib
2 ) Find the odd one
(i) DB2
(ii) Oracle
(iii)MS-Access
(iv) Sql Server
(v) Javascript
so i can not fix the number of radio buttons.Some questions may have multiple answers.so i need to display checkboxes instead of radio buttons.
My Question is how to generate Radio Buttons or Checkboxed Dynamically ?
Create a RadioButtonList or CheckBoxList for each question and use its Items collection to add the answers.
Very simple example in C#:
class Question
{
public string QuestionText;
public List<string> Answers;
}
protected void AddQuestionsToContainer(Control container, List<Question> questions)
{
foreach (Question q in questions)
{
var qt = new Label();
qt.Text = q.QuestionText;
container.Controls.Add(qt);
var rbl = new RadioButtonList();
foreach (string answer in q.Answers)
{
rbl.Items.Add(new ListItem(answer));
}
container.Controls.Add(rbl);
}
}
I think your question more specifically is how to decide which quiz question has multiple answers.
If I'm correct than you need to have an extra column like isMultipleAnswers BIT in the table in DB (or whatever the source is you need to have a flag for each question), and handle a event for the DetailView like DataBinding, check the value for this field, based on that either add RadioButtonList or CheckBoxList.
Hope this helps!
BTW, why aren't you using Repeater??
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm looking for a decent paging control in ASP.NET, much like the Stackoverflow pager. Can anyone recommend one?
I'd prefer one that didn't use Postback either, just a customisable querystring.
It's quite easy to roll your own. I created a simple user control based on the stack overflow pager with two properties...
Total number of pages available according to the underlying data
Number of links to show
The selected page is determined by reading the query string. The biggest challenge was altering the URL with the new page number. This method uses a query string parameter 'p' to specify which page to display...
string getLink(int toPage)
{
NameValueCollection query = HttpUtility.ParseQueryString(Request.Url.Query);
query["p"] = toPage.ToString();
string url = Request.Path;
for(int i = 0; i < query.Count; i++)
{
url += string.Format("{0}{1}={2}",
i == 0 ? "?" : "&",
query.Keys[i],
string.Join(",", query.GetValues(i)));
}
return url;
}
A simple formula to determine the range of page numbers to show...
int min = Math.Min(Math.Max(0, Selected - (PageLinksToShow / 2)), Math.Max(0, PageCount - PageLinksToShow + 1));
int max = Math.Min(PageCount, min + PageLinksToShow);
Each link then gets generated using something like (where min and max specify the range of page links to create)...
for (int i = min; i <= max; i++)
{
HyperLink btn = new HyperLink();
btn.Text = (i + 1).ToString();
btn.NavigateUrl = getLink(i);
btn.CssClass = "pageNumbers" + (Selected == i ? " current" : string.Empty);
this.Controls.Add(btn);
}
One can also create 'Previous' (and 'Next') buttons...
HyperLink previous = new HyperLink();
previous.Text = "Previous";
previous.NavigateUrl = getLink(Selected - 1);
The first and last buttons are straight forward...
HyperLink previous = new HyperLink();
previous.Text = "1";
first.NavigateUrl = getLink(0);
In determining when to show the "...", show a literal control when the link range is not next to the first or last pages...
if (min > 0)
{
Literal spacer = new Literal();
spacer.Text = "…";
this.Controls.Add(spacer);
}
Do the same for above for "max < PageCount".
All of this code is put in an override method of CreateChildControls.
I was expecting more answers but it looks like a lot of people just make their own. I've found a decent one that is maintained quite often on codeproject.com
It's not quite the same as the stackoverflow.com one. It'd be nice if there was a decent open source control that had a variety of different output options.
I've worked with the DevExpress and Telerik page controls and prefer the DevExpress pager. I'm not sure if the DevExpress pager can work directly with a querystring but I would be surprised if it didn't as it is very flexible. As far as paging between existing pages after download, everything can reside on the client or, if a trip to the server is necessary, the control is fully AJAX equipped. I suggest you start your search at www.devexpress.com and then check out www.Telerik.com as well (which is also AJAX equipped).
Not a control, but this is the way to implement paging at the DB level: SQL Server 2005 Paging
I have written a pager control named: Flexy Pager
Read more: http://www.codeproject.com/Articles/748270/Flexy-Pager-for-ASP-NET-WebForm-MVC
You can try NPager. Uses query string for page indexes, no postbacks. Needs Bootstrap for styling, however you can have your own custom css classes for the control using 'pagination' CSS class.Here is a working DEMO