on 07-23-2010 7:45 PM
Hi,
could any one help me with the code for the below scenario
i have a node stud_inp with cardinalyty 0:1 and String attributes fname, lname,this forms the input form with input fields in the view view and setting the user input in the table node stud_tab with the same attribute fields, but every time the application launches the input field are disaabled
here is the code i wrote on onAction submit:
IWDNodeElement eleme = this.wdContext.currentStud_inpElement();
String fname = eleme.getAttributeAsText("fname");
String lname = eleme.getAttributeAsText("lname");
String rollno = eleme.getAttributeAsText("rollno");
String sec = eleme.getAttributeAsText("sec");
IPrivateStart_view.IStud_tabElement elem = wdContext.nodeStud_tab().createStud_tabElement();
elem.setFirst_name(fname);
elem.setLast_name(lname);
elem.setRoll_No(rollno);
elem.setSection(sec);
wdContext.nodeStud_tab().addElement(elem);
Hi Akeel,
Are you trying the use the InputFields fname,lname etc on your screen to fill the values in your table having the fields with the same name?
Your inputFields are disabled because you have bound them to the attributes of the node Stun_inp having 0..1 cardinality. In order to enable the inputDields, you should create an element of that node. In order to achieve your functionality
Try the following:
Change the Cardinality of your Stud_inp node to 1..1 so that you don't have to create the element. and the InputFields will be enabled.
Then change the code as follows:
IStud_inpElement eleme = wdContext.currentStud_inpElement();
IPrivateStart_view.IStud_tabElement elem = wdContext.nodeStud_tab().createStud_tabElement();
elem.setFirst_name(eleme.getFname());
elem.setLast_name(eleme.getLname());
elem.setRoll_No(eleme.getRollno());
elem.setSection(eleme.getRollno());
wdContext.nodeStud_tab().addElement(elem);
However, you can achieve this functionality even without creating the Stud_inp node.
You could just create the Value attributes for your Fname, Lname etc. instead of creating a node for them and bind them to your InputFields. Then you could set the values in the Stud_tab node as follows :
IPrivateStart_view.IStud_tabElement elem = wdContext.nodeStud_tab().createStud_tabElement();
elem.setFirst_name(wdContext.currentContextElement().getFname());
elem.setLast_name(wdContext.currentContextElement().getLname());
elem.setRoll_No(wdContext.currentContextElement().getRollno());
elem.setSection(wdContext.currentContextElement().getRollno());
wdContext.nodeStud_tab().addElement(elem);
Regards,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anil,
thanks for the reply and yes the cardinality was indeed the issue , changing from 0:1 to 1:1 saved the day ,however below is the interospection for your valuable comments
1. IStud_inpElement gave an error as it could not recognise it
2 belwo is the code i replsced ,
IWDNodeElement eleme = wdContext.nodeStud_inp().currentStud_inpElement();
String fname = eleme.getAttributeAsText("fname");
String lname = eleme.getAttributeAsText("lname");
String rollno = eleme.getAttributeAsText("rollno");
String sec = eleme.getAttributeAsText("sec");
IPrivateStart_view.IStud_tabElement elem = wdContext.nodeStud_tab().createStud_tabElement();
elem.setFirst_name(fname);
elem.setLast_name(lname);
elem.setRoll_No(rollno);
elem.setSection(sec);
wdContext.nodeStud_tab().addElement(elem);
Akeel,
Is the issue resolved?
If yes thn close the thread otherwise let us know the issue you are experiencing now.
You said the IStud_inpelement was not recognized. In order for it to be recognized, you have to organize imports by pressing ctrlshiftO in the Java Editor by right clicking in the editor and then Source->Organize Imports.
Also if the Stud_inp Node is in the same view, then you can declare the IStud_inpElement the same way you did for the IStud_tabElement i.e. IPrivateStart_view.IStud_inpElement
Regards,
Ajay
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.