Results 1 to 18 of 18
Thread: Multiple Multishuffles
- 11-08-2010, 02:24 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
Multiple Multishuffles
Hello everyone I use Jdeveloper 11g R2 and have 3 multishuttles on my jsp that are all supposed to refresh when navigation buttons are pressed.
This means all the multishuttle code should be in a single backing bean, so the navigation button could call the refresh method from that bean, which would refresh all three.
This is the code I have
Unfortunately this comes with problems when commiting the values (the refresh works), as the values are not stored in the database, and I get a commit value problem output message. If I put them in separate java classes it works, and will commit for all three, but the refresh button only works for one multishuttle (the one that has the method it uses for action).Java Code:package view.backingbeans; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import view.objekti.utils.JSFUtils; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import oracle.adf.model.BindingContext; import oracle.adf.model.binding.DCBindingContainer; import oracle.adf.model.binding.DCIteratorBinding; import oracle.adf.view.rich.component.rich.nav.RichCommandToolbarButton; import oracle.binding.AttributeBinding; import oracle.binding.BindingContainer; import oracle.binding.OperationBinding; import oracle.jbo.Row; import oracle.jbo.domain.Number; public class FormShuttle { private RichCommandToolbarButton Next1; public FormShuttle() { super(); } List selectedFruits; List allFruits; List selectedTerminali; List allTerminali; Boolean refreshSelectedList = false; public void setSelectedFruits(List selectedItems) { this.selectedFruits = selectedItems; } public List getSelectedFruits() { if (selectedFruits == null || refreshSelectedList) { selectedFruits = attributeListForIterator("KonekcijeView1Iterator", "AdslId"); // attributeListForIterator("TerminaliUObjektuView1Iterator", "TipTerminalaId"); } return selectedFruits; } public void setAllFruits(List allItems) { this.allFruits = allItems; } public static List attributeListForIterator(String iteratorName, String valueAttrName) { BindingContext bc = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bc.getCurrentBindingsEntry(); DCIteratorBinding iter = binding.findIteratorBinding(iteratorName); List attributeList = new ArrayList(); for (Row r : iter.getAllRowsInRange()) { attributeList.add(r.getAttribute(valueAttrName)); } return attributeList; } public List getAllFruits() { if (allFruits == null) { allFruits = selectItemsForIterator("AdslView1Iterator", "AdslId", "TipKonekcije"); } return allFruits; } public static List<SelectItem> selectItemsForIterator(String iteratorName, String valueAttrName, String displayAttrName) { BindingContext bc = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bc.getCurrentBindingsEntry(); DCIteratorBinding iter = binding.findIteratorBinding(iteratorName); List<SelectItem> selectItems = new ArrayList<SelectItem>(); for (Row r : iter.getAllRowsInRange()) { selectItems.add(new SelectItem(r.getAttribute(valueAttrName), (String)r.getAttribute(displayAttrName))); } return selectItems; } public void refreshSelectedList() { refreshSelectedList = true; } public Number getCurrentPersonId() { BindingContext bctx = BindingContext.getCurrent(); DCBindingContainer bindings = (DCBindingContainer)bctx.getCurrentBindingsEntry(); AttributeBinding attr = (AttributeBinding)bindings.get("ObjekatId2"); Number personId = (Number)attr.getInputValue(); return personId; } public String processShuttle() { BindingContext bctx = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bctx.getCurrentBindingsEntry(); DCIteratorBinding iter = (DCIteratorBinding)binding.get("KonekcijeView1Iterator"); //Removing all rows for (Row r : iter.getAllRowsInRange()) { r.remove(); } if (this.getSelectedFruits().size() > 0) { for (int i = 0; i < selectedFruits.size(); i++) { Row row = iter.getRowSetIterator().createRow(); row.setNewRowState(Row.STATUS_INITIALIZED); row.setAttribute("ObjekatId", getCurrentPersonId()); row.setAttribute("AdslId", getSelectedFruits().get(i)); iter.getRowSetIterator().insertRow(row); iter.setCurrentRowWithKey(row.getKey().toStringFormat(true)); System.out.println("inside "); } } String ok = doCommit(); System.out.println("Commit value" + ok); return null; } public String doCommit() { BindingContainer bindings = getBindings(); OperationBinding operationBinding = bindings.getOperationBinding("Commit"); Object result = operationBinding.execute(); if (operationBinding.getErrors().isEmpty()) { /* List errors = operationBinding.getErrors(); Iterator<oracle.jbo.JboException> iterator = errors.iterator(); while (iterator.hasNext()) { FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, iterator.next().getMessage(), null); FacesContext fctx = FacesContext.getCurrentInstance(); fctx.addMessage(null, fm); } */ return "problem"; } return "ok ki flight"; } public void setSelectedTerminali(List selectedItems) { this.selectedTerminali = selectedItems; } public List getSelectedTerminali() { if (selectedTerminali == null || refreshSelectedList) { selectedTerminali = attributeListForIterator2("TerminaliUObjektuView1Iterator", "TipTerminalaId"); } return selectedTerminali; } public void setAllTerminali(List allItems) { this.allTerminali = allItems; } public static List attributeListForIterator2(String iteratorName, String valueAttrName) { BindingContext bc = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bc.getCurrentBindingsEntry(); DCIteratorBinding iter = binding.findIteratorBinding(iteratorName); List attributeList = new ArrayList(); for (Row r : iter.getAllRowsInRange()) { attributeList.add(r.getAttribute(valueAttrName)); } return attributeList; } public List getAllTerminali() { if (allTerminali == null) { allTerminali = selectItemsForIterator2("TipTerminalaView1Iterator", "TipTerminalaId", "Naziv"); } return allTerminali; } public static List<SelectItem> selectItemsForIterator2(String iteratorName, String valueAttrName, String displayAttrName) { BindingContext bc = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bc.getCurrentBindingsEntry(); DCIteratorBinding iter = binding.findIteratorBinding(iteratorName); List<SelectItem> selectItems = new ArrayList<SelectItem>(); for (Row r : iter.getAllRowsInRange()) { selectItems.add(new SelectItem(r.getAttribute(valueAttrName), (String)r.getAttribute(displayAttrName))); } return selectItems; } { refreshSelectedList = true; } public Number getCurrentObjekatId() { BindingContext bctx = BindingContext.getCurrent(); DCBindingContainer bindings = (DCBindingContainer)bctx.getCurrentBindingsEntry(); AttributeBinding attr = (AttributeBinding)bindings.get("ObjekatId2"); Number objekatId = (Number)attr.getInputValue(); return objekatId; } public String processShuttle2() { BindingContext bctx = BindingContext.getCurrent(); DCBindingContainer binding = (DCBindingContainer)bctx.getCurrentBindingsEntry(); DCIteratorBinding iter = (DCIteratorBinding)binding.get("TerminaliUObjektuView1Iterator"); //Removing all rows for (Row r : iter.getAllRowsInRange()) { r.remove(); } if (this.getSelectedTerminali().size() > 0) { for (int i = 0; i < selectedTerminali.size(); i++) { Row row = iter.getRowSetIterator().createRow(); row.setNewRowState(Row.STATUS_INITIALIZED); row.setAttribute("ObjekatId", getCurrentObjekatId()); row.setAttribute("TipTerminalaId", getSelectedTerminali().get(i)); iter.getRowSetIterator().insertRow(row); iter.setCurrentRowWithKey(row.getKey().toStringFormat(true)); System.out.println("inside "); } } String ok = doCommit(); System.out.println("Commit value" + ok); return null; } public BindingContainer getBindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } public String previous_action() { BindingContainer bindings = getBindings(); OperationBinding operationBinding = bindings.getOperationBinding("Previous"); Object result = operationBinding.execute(); if (!operationBinding.getErrors().isEmpty()) { return null; } refreshSelectedList(); return null; } public String adslSljedeciButton_action() { if(((Boolean)JSFUtils.getManagedBeanValue("bindings.Commit.enabled")) == false) { BindingContainer bindings = getBindings(); OperationBinding operationBinding = bindings.getOperationBinding("Next1"); Object result = operationBinding.execute(); if (!operationBinding.getErrors().isEmpty()) { return null; } } else { FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Napravili ste neke izmjene morate ih prvo pohraniti ili povratiti" + " prije nego mozete nastaviti!", null)); } refreshSelectedList(); return null; } public void setNext1(RichCommandToolbarButton Next1) { this.Next1 = Next1; } public RichCommandToolbarButton getNext1() { return Next1; } }
I am a beginner in Java so really any help would be greatly appreciated.
- 11-08-2010, 02:36 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
I don't know adf, and I suspect there aren't many here who do, but this:
looks wrong. Surely if there are no errors then there isn't a problem?Java Code:if (operationBinding.getErrors().isEmpty()) { return "problem"; }
Anyway, I suspect you'd have better luck over at OTN.
- 11-09-2010, 08:06 AM #3
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
Reply
I have posted at OTN but so far no luck with the answer, I was hoping that this thing I was doing was java, not adf. I mean I implement it in the page using adf but im pretty sure the code was written in Java, thats why I posted here. But as I said I am a total newbie at this stuff so you guys probably know better.
- 11-09-2010, 09:04 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
Except the ADF stuff is (for me) disguising any problems you might be having with your data or queries.
Oh, and I have no idea what a multishuttle is...which isn't helped by the language issue so I can't even guess at what it is you are doing. That bit isn't, of course, your fault...;)
- 11-09-2010, 09:17 AM #5
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
A multishuttle is just my name for a select many shuttle component, a component that has 2 boxes with lists in them and buttons in between for switching list items between.
In other words you solve a many to many in that you have in the left list all available items, and in the right selected items. The user can then choose items he selects.
- 11-09-2010, 10:12 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
OK.
So why do you need an Ajax component?
Doesn't the user simply save the page once they're happy with the items in the selected box?
- 11-09-2010, 10:57 AM #7
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
There is a save button to save the changes in the database yes but it doesn't work it gives me errors. Also which Ajax component do you mean? Do you mean the Shuttle? The shuttle is the easiest way to give an interface to a many to many relationship which allows users to add and remove items from the intersection table.
- 11-09-2010, 11:33 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
I suspect I'm confusing myself.
I seem to have mangled two threads together in my head!
:)
I have no idea where I got the Ajax thing from...oopsie.
Right, so you are clicking save and sending the data from the client to the server.
What data are you getting?
In fact, what exception are you getting?
Errors?
Where from?
- 11-09-2010, 11:46 AM #9
The cross post is at
OTN Discussion Forums : 3 Multi Shuttles on a page that are all ...
db
- 11-09-2010, 11:59 AM #10
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
I did some tests. If I comment out (/*, */) everything after the do commit line, so
from here
then It works for the remaining shuttle (the fruits one). But something in there is messing it up so that when I press commit, it not only doesn't commit it throws out everything that was in the table (it deletes all data in the intersection table).Java Code:/* public void setSelectedTerminali(List selectedItems) { this.selectedTerminali = selectedItems; }
I then tried commenting out partial stuff like the procesShuttle2 and doCommit but even if both are commented out and I put them in a different java class (so I put the 2 commit buttons action attributes to 2 different java classes) it still throws the same error.
Thing is if I separate them completely, so 2 java classes for two shuttles, it works, the only problem then is navigation, as I can't get one navigation button to refresh both shuttles because there are 2 refresh methods in 2 classes.
Hope this made some sense (although i doubt it)
- 11-09-2010, 01:13 PM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
You still haven't told us what errors you're getting, in any of these situations.
- 11-09-2010, 01:19 PM #12
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
I don't get an error. As I said what happens is that when I press save instead of saving data in the database it deletes the data in the table (not just one row either but all the data).
Thing is as you can see from the code, there are some println statements that fire for certain conditions and I get an output that says
Commit valueProblem.
However even when I had only one shuttle and it worked, it would print out
inside
Commitvalue
I got this code from a blog so not quite sure what the deal is.
- 11-09-2010, 01:41 PM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
You're going to need to add more debugging code in there then.
For example is that "CommitValue" output coming from processShuttle() or processShuttle2()?
That "Problem" part of the output comes from the code I quoted in my first post.
The code I thought looked odd.
But this is all down to ADF or JBO...I can see where you are removing rows, and I think I can see the inserts, and possibly the commit (surely that's not really how you commit with this stuff??), but I can't say more than that.
ETA: As for code from a blog, don't go copying stuff until you know the technology that it's using.
- 11-09-2010, 01:46 PM #14
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
You don't understand. processShuttle and processShuttle 2 are the same pieces of code. Except for 2 different shuttles. But the code itself is exactly the same, just the variables are changed.
The guy who has the blog told me this
"why you are duplicating your code for every shuttle ? yes you can do this in same java class.
The methods attributeListForIterator and the other one are parameter based so you need to just pass the name of iterator to work.
Same thing call the refresh method in navigation operations. when refreshSelectedList value will be true your shuttle will refresh
I think you better look at basics of java before writing code"
I did copy the code and just put in the variables for the second shuttle, and thats probably the problem but not sure how to solve it.
- 11-09-2010, 02:02 PM #15
Yet another crosspost: Multiple Multishuffles - Java Programming Forums
- 11-09-2010, 02:04 PM #16
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
He's quite right, you know.
This stuff is not basic and if your grasp of the technology here isn't up to scratch then you are not going to get this to work. You're going to have to learn the technology involved. And the problems you are having seem to stem from the db interactions.
- 11-09-2010, 02:06 PM #17
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
Yes you are no doubt right but I don't have time now to devote myself to learning Java. I have to finish this project first and then I should have time to finish this. There was talk of sending me to some courses but so far none of that has materialised and yet I still need to finish this.
- 11-09-2010, 02:42 PM #18
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
Similar Threads
-
Running multiple threads on multiple CPU cores?
By Dosta in forum Threads and SynchronizationReplies: 2Last Post: 09-19-2010, 03:48 PM -
Use multiple forms
By coco in forum Java AppletsReplies: 2Last Post: 06-14-2010, 05:14 AM -
Multiple Views
By MrDave in forum AWT / SwingReplies: 8Last Post: 04-09-2010, 09:20 PM -
multiple program
By mm2236 in forum Threads and SynchronizationReplies: 2Last Post: 10-02-2009, 12:27 PM -
Multiple window
By shoeb83 in forum New To JavaReplies: 1Last Post: 08-30-2009, 10:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks