SelectManyCheckBox in a transaction?

Forum sobre a ferramenta Oracle JDeveloper, ADF, OAF, etc. (Não é destinado ao aprendeziado da Linguagem Java em geral)
Post Reply
rohling
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 20
Joined: Wed, 26 Aug 2009 7:43 pm
Location: PR

As I create an example registration:
- employees for many departments, where in this screen will record in the employee table and also in the Table Department to their respective ID.
- Using Trigger to record the official ID which will have to be recorded 1st, so that it is recorded this same ID in the Departmentary Table. Would you like this to be held in a single transaction? It is possible? How would the Record button method would be?

Sincerely ...
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

if you had a relationship of type 1 official for 1 department would be simple in the official table you would record the pk of the department as fk and everything solved but you have 1 for n soon you will need another table to do this .. these associative table guadará The key to your employee plus the key of a department so you can have a function with more than one department because each record of this table will be an association between Func and Depth, so the name of it and associative.

With relation to your Technical Doubt you have to give more data ..
If you are using BC, simply deploy a Calde PostChange method in the EO of the main entity (FUNC) and in the And department refreshkey ... (I can not remember the right name now) so you can save the parent entity and daughter in the same transaction ..

if you want to do this in the hand and easier ... Just put the trigger in this new table ..

for the button .. I need to know which framework is using

I hope I have helped ... Senao Clarify better that I will try to help you

Embrace
rohling
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 20
Joined: Wed, 26 Aug 2009 7:43 pm
Location: PR

VICTOR:

I am using ADF in jdeveloper 11g with BD Oracle and would like to imply this in the same hand at the time of running the save button. I already have JSPX with the employee registration and checkbok with the departments, but I would like to be reading the Checbok from the selected departments and venues in the feature table with this saved officer ID and this in the same transaction.

This other solution commented "I did not understand when wrote:" Just put the trigger in this new table "would be to implement all this direct in the bank?

Thanks,
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

assuming that your model is right ..

I do not see problems in making two commits because the adf bussines components has its modules applications just for you not to worry about issues of bank transactions ..

Understand your problem .. You have the creation of a worker that when you create a temporary negative ID and before giving the commit, where the trigger will enter into action to feed the true ID generated by Sequence From this table, you want to use this id to insert into another table (funcdep) as fk ... yes .. of to do but get a shit ..

you want I can post more Afternoon these methods that would be implemented in the EOS to update this negative PK temporarily and to be able to update your other table, but I am advancing that, from behind the cloths, you will be doing the same thing as giving your dbtrasaction.commit ()

has this other way also that I found ... http://one-size-doesnt-fit-all.blogspot ... reate.html
in the CREATE () method of EO that is triggered when you a creatinsert in your vo, it already goes in the bank read the value of the sequence and already arrow the actual value of the ID of the new official soon and only pick up and save in your associative table

ai
I hope I have helped
Embrace
rohling
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 20
Joined: Wed, 26 Aug 2009 7:43 pm
Location: PR

VICTOR:
Making two Commit I am afraid of recording on the 1st table (FUNC) and at the moment give another Commit to give a power drop, etc. and not record on the 2nd table (Funcdep). If possible sends me these methods implemented in the EOS, I agree that in that way it will be a *** a ...


Sincerely,
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

these are the methods that I told you ...



does not forget that this entity operating services will have to be duly figured in its system through and the and vl
rohling
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 20
Joined: Wed, 26 Aug 2009 7:43 pm
Location: PR

VICTOR:
I made all the methods, I am having difficulty receiving the selected checkbox values, through an action in my good.
In JSPX is like this:

Select all

<af:selectManyCheckbox value="#{bindings.DepView1.inputValue}" 
                                   label="#{bindings.DepView1.label}" 
                                   binding="#{backingBeanScope.backing_untitled1.smc2}" 
                                   id="smc2"> 
              <f:selectItems value="#{bindings.DepView1.items}" 
                             binding="#{backingBeanScope.backing_untitled1.si3}" 
                             id="si3"/> 
            </af:selectManyCheckbox>
Sincerely,
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

What difficulty?
Generates someone error?
Are the values ??are not coming to your method?

So face ..

1 - Try to put in your component

Select all

valuePassThru=true
2 -

Select all

binding="#{backingBeanScope.backing_untitled1.smc2}"
You have the selected values ??through this Q attribute was created in your managedbean (or backingbean)
rohling
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 20
Joined: Wed, 26 Aug 2009 7:43 pm
Location: PR

VICTOR:

Consequently do what I wanted: to record in 2 tables in the same transaction 01 employee for several departments; This thanks to the methods that you had passed the links, I will post the code I think can be improved:
In my department CheckBox I attribute the value that comes from the following backingbean array:

99]] Private Integer [] DepartmentsSelected;

In JSPX:

Select all

<af:selectManyCheckbox value="backingBeanScope.backing_untitled1.departamentosSelecionados}"
In BackingBean I created this method that is triggered in the Action of the Record button:

Select all

 public String gravar() { 
        DCBindingContainer bc = getDCBindingContainer(); 
        DCIteratorBinding iterDep = bc.findIteratorBinding("DepView1Iterator"); 
        DCIteratorBinding iterFuncionario = bc.findIteratorBinding("FuncView1Iterator"); 
        DCIteratorBinding iterDepFunc =   bc.findIteratorBinding("FuncdepView1Iterator"); 
 
        Row newRowFuncionario = iterFuncionario.getCurrentRow(); 
        oracle.jbo.domain.DBSequence idfunc =(oracle.jbo.domain.DBSequence)newRowFuncionario.getAttribute("Idfunc"); 
        for (int i : getDepartamentosSelecionados()) { 
           // aqui o valor de i retorna sempre um indice começando do 0,1,2... Gostaria que já receber o valor da chave  
  	   // para não necessitar fazer a pesquisa abaixo? 
 
            iterDep.setCurrentRowIndexInRange(i); 
            Row newRow = iterDep.getCurrentRow(); 
            oracle.jbo.domain.DBSequence iddep = (oracle.jbo.domain.DBSequence)newRow.getAttribute("Iddep"); 
          
           // aqui é uma gambi..  inclui um botão CreateInsert1 de FuncdepView1Iterator para poder aqui 
           // incluir um novo registro; deve ter outra maneira de fazer isso? 
            OperationBinding InsertFuncDepOper =   bc.getOperationBinding("CreateInsert1"); 
            InsertFuncDepOper.execute(); 
            Row newRowDepFuncionario = iterDepFunc.getCurrentRow(); 
            newRowDepFuncionario.setAttribute("Funcid", idfunc); 
            newRowDepFuncionario.setAttribute("Depid", iddep); 
 
        } 
        oracle.binding.OperationBinding operationBinding =  bc.getOperationBinding("Commit"); 
        operationBinding.execute(); 
 
        return null; 
    } 
]]
As I am studying is tool to start in system production as it could improve this method above
regards,
Rohling
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

in terms of technology and difficult to comment posions there are several ways to use this then your way and one more way and it is not "wrong" ...

what I see can be improved and the question of oo and project patterns in the case mvc ..

in the part where you create the row of dep você you could be doing it inside your am logo cahamdas of the type

Select all

 
        DCBindingContainer bc = getDCBindingContainer(); 
        DCIteratorBinding iterDep = bc.findIteratorBinding("DepView1Iterator"); 
would be eliminated and also if it is necessary to validate if that official already exists for that department you will make it there in your controller (backing bean) and then it will not be very coherent ..

Separate this into more best defined methods defined type setPartamentoPortamento and another record and do not forget its validate

OperationBinding calls should also be used for customized methods of your am and should be included in your methods of a methodaction

I hope I have helped
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests