on 01-30-2007 11:06 AM
Hello all,
i am new to webDynpro!
I wanna create a dynamic tree. In my application there are 2 views in a ViewSet. One view "Tree"for tree, another view "Question" contains a inputfield for typing a question.
Componentcontroller includes a value node "QuestionNode", in"QuestionNode" there are a value attribute "text." Then mapping the Componnentcontrller to the both views"Tree".
When i types a question in "question" view and Enter, then automatic insert a node in "tree"View.
this tree has only parent node ,no child. text of node is the value attribute"text" . The text ,which i have typed in inputfield in "Question" view, is displayed in the tree.
plx give me some code and tips.
Thx in advance
regards
Yaning
Message was edited by:
Yaning Liu
Why do you want to use a tree here? I cannot see any hierarchy.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"nur a example"
Ok, so you perhaps need a recursive tree structure like
Context:
- QuestionText (attribute, string)
- Questions (node)
--- Text (attribute, string)
--- SubQuestions (recursive node, RepeatedNode = Questions)
View Layout:
InputField.value = QuestionText
InputField.onEnter = AddQuestion
Tree.dataSource = Questions
TreeNodeType.dataSource = Questions
TreeNodeType.text = Questions.Text
Action "AddQuestion":
Implement the action handler like
try
{
IQuestionsElement selectedQuestion = (IQuestionsElement) wdContext.nodeQuestions().getTreeSelection();
IQuestionsElement newQuestion;
if (selectedQuestion == null)
{
newQuestion = wdContext.nodeQuestions().createAndAddQuestionsElement();
}
else
{
newQuestion = selectedQuestion.nodeSubQuestions().createAndAddQuestionsElement();
}
newQuestion.setText(wdContext.currentContextElement().getQuestionText());
}
catch (WDContextException e)
{
wdComponentAPI.getMessageManager().reportException(e.getMessage());
}
This will add a new question node under the currently selected node or under the root if no node is selected.
Armin
Hello Armin,
another problem comes. can you give me some advices?
Now i have three views : "Question" ,"Tree" , "SubQuestion"
all controllers are already mapped.
Context: for ComponentController and 3 ViewController
- Question (node)
-
Text (attribute, string)
-
SubQuestion (recursive node, RepeatedNode = Question)
Question (Node)
--cardinality 0..n
--collectionType list
--initializeLeadSelection true
--selection 0..1
--singleton true
--typedAccessRequired true
"Question" View Layout:
Button.OnAction = ToSubQuestion ---(jump to "SubQuestion" View for choosing the parent, i.e )
InputField.value = QuestionText
"SubQuestion" View Layout: (This view contains a table with a column "Question.Text". all questions stand in this table. i will select a question als parent)
--- Table.dataSource = Question
--- Table.onLeadSelect = Select ( back to "QuestionView" and i hope, the current element is the new created subQuestion)
--- one Column
-
TableCellEditor.Text = Question.Text
"Tree" View LayOut
--- Tree.dataSource = Question
--- TreeNodeType.dataSource = Question
--- TreeNodeType.text = Question.Text
Action "Select":
public void onActionSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent,
com.sap.tut.wd.test1.wdp.IPrivateSubQuestionView.IQuestionElement selectedElement )
{
//@@begin onActionSelect(ServerEvent)
IPrivateSubQuestionView.IQuestionNode subQuestionNode = wdContext.currentQuestionElement().nodeSubQuestion();
IPrivateSubQuestionView.IQuestionElement subQuestion;
subQuestion = subQuestionNode.createQuestionElement();
subQuestionNode.addElement(subQuestion);
subQuestionNode.setTreeSelection(subQuestion);
wdThis.wdFirePlugBackQuestionOut();
//@@end
}
The Problem :
when i select a question als parent, jump back to "Question"View. I hope ,the current NodeElement is kind (SubQuestion), but in fact parent .
i don't Know, how set the LeadSelection or TreeSelection of recursive Node (Non-Singleton child node).
i think ,the problem is
subQuestionNode.setTreeSelection(subQuestion);
i can't set the recursive node element als current element.
can you give me some code.
Thx in Adcance.
regards
Yaning
HI Yaning Liu ,
What do you want to diplay in the tree.
With Regards
Naidu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.