[JBoss Seam] - Re: IllegalArgumentException: Stack must not be null
by gaboo
well, indeed.Here is the complete asynchronous method :
@Stateless
| 36 @Name("importRunAction")
| 37 public class ImportRunAction implements ImportRunActionInterface {
| 38
| 39 @In
| 40 EntityManager entityManager;
| 41
| 42 public ImportRunAction() {
| 43 }
| 44
| 45 @Override
| 46 public void run(Import importRule, User user) {
| 47
| 48 int bookCount = 0;
| 49 boolean success = true;
| 50 File passthroughData = null;
| 51 Datasource datasource = importRule.getDataSource();
| 52
| 53 List<Object> passthroughMetaData = null;
| 54 List<MicroStepAction> microActions = new ArrayList<MicroStepAction>();
| 55
| 56 Collection<DataType> previousDataType;
| 57 previousDataType = new ArrayList<DataType>();
| 58 previousDataType.add(DataType.NONE);
| 59
| 60 Event importRunEvent = Tools.getNewEvent();
| 61 importRunEvent.setUser(user);
| 62 importRunEvent.setIsParent(true);
| 63 importRunEvent.setObjectType(IMPORT);
| 64 importRunEvent.setName(datasource.getName());
| 65
| 66 importRule.setStartDate(new Date(System.currentTimeMillis()));
| 67
| 68 /*
| 69 * Asynchronous and ongoing task progress reporting
| 70 */
| 71 AsynchronousImportController aip = (AsynchronousImportController) Component
| 72 .getInstance("asynchronousImportController");
| 73 Progress progress = aip.getProgress(importRule);
| 74
| 75 try {
| 76 for (MicroStep m : importRule.getMicroSteps()) {
| 77 if (!m.isEnabled()) {
| 78 continue;
| 79 }
| 80 if (!m.acceptInputDatas(previousDataType)) {
| 81 FacesMessages.instance().addFromResourceBundle(
| 82 "lrb.error.import.incorrectPreviousData");
| 83 aip.remove(importRule);
| 84 throw new Exception(
| 85 m.getName()
| 86 + " "
| 87 + Tools
| 88 .getTranslation("lrb.error.import.incorrectPreviousData"));
| 89 }
| 90 MicroStepAction msa = (MicroStepAction) Class.forName(
| 91 "com.lrb.dataImport.microStepActions."
| 92 + m.getClass().getSimpleName() + "Action")
| 93 .newInstance();
| 94 msa.setProgress(progress);
| 95 microActions.add(msa);
| 96 msa.setMicroStep(m);
| 97 msa.setInputData(passthroughData);
| 98 msa.setInputMetaData(passthroughMetaData);
| 99
| 100 /* Add all the parameters */
| 101 msa.addParameter("user", user);
| 102 msa.addParameter("datasource", datasource);
| 103 msa.addParameter("table", importRule.getDataSource()
| 104 .getTableName());
| 105
| 106 /* Actually run the microStepAction */
| 107 success = success && msa.run();
| 108
| 109 msa.getEvent().setName(
| 110 datasource.getName() + ":" + msa.getEvent().getName());
| 111 importRunEvent.addChild(msa.getEvent());
| 112
| 113 if (success) {
| 114 passthroughData = msa.getOutputData();
| 115 passthroughMetaData = msa.getOutputMetadata();
| 116 previousDataType = m.getOutputDataType();
| 117
| 118 // extract the number of rows
| 119 Object parameter = msa.getParameter("rowCount");
| 120 if (parameter != null && parameter instanceof Integer) {
| 121 bookCount = (Integer) parameter;
| 122 if (bookCount > 0) {
| 123 datasource.setBookCount(bookCount);
| 124 }
| 125 }
| 126 } else {
| 127 FacesMessages.instance().addFromResourceBundle("lrb.error.import.failed");
| 128 importRunEvent.setMessage("Failure");
| 129 importRunEvent.end();
| 130 entityManager.persist(importRunEvent);
| 131 for (MicroStepAction action : microActions) {
| 132 action.cleanUp();
| 133 }
| 134 aip.remove(importRule);
| 135 throw new Exception(importRunEvent.getMessage());
| 136 }
| 137
| 138 importRunEvent.setMessage("Success");
| 139 importRunEvent.end();
| 140 entityManager.persist(importRunEvent);
| 141 }
| 142
| 143 } catch (Exception e) {
| 144 FacesMessages.instance().add(e.getMessage());
| 145 for (MicroStepAction msa : microActions) {
| 146 msa.cleanUp();
| 147 }
| 148 e.printStackTrace();
| 149 aip.remove(importRule);
| 150 }
| 151
| 152 for (MicroStepAction msa : microActions) {
| 153 msa.cleanUp();
| 154 }
| 155 aip.remove(importRule);
| 156
| 157 datasource.setBookCount(bookCount);
| 158
| 159 // TODO : find a way to make this work
| 160 // entityManager.merge(datasource);
| 161 }
| 162 }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098597#4098597
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098597
18Â years, 6Â months
[JBoss Seam] - Exceptions in page param converters
by adamw
Hello,
I have an @ApplicationException, which I want to handle with Seam.
In particular, I want to convert a page parameter to an entity, and if the page parameter points to a non-existing entity, an exception is thrown.
The exception is defined as follows:
| <exception class="item.ItemNotFoundException">
| <redirect view-id="/error.xhtml">
| <message severity="ERROR">The item was not found.</message>
| </redirect>
| </exception>
|
If I do:
| <page view-id="/item/item_view.xhtml" action="#{itemView.loadItem}">
| <param name="name" value="#{itemView.itemName}" />
| </page>
|
and the "#{itemView.loadItem}" method throws an exception, the browser redirects to /error.xhtml, and the message is displayed.
But if I do:
| <page view-id="/item/item_edit.xhtml">
| <param name="name" value="#{itemEdit.item}" converter="#{itemConverter}" />
| </page>
|
and the converter throws an excpetion, the browser still redirects to /error.xhtml, but the message is not displayed. How can I change that? Obviously, conversion happens at an earlier phase than rendering the response, so the exception can be caught (and is :) ), but maybe I don't see the message because the conversation context isn't yet created?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098591#4098591
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098591
18Â years, 6Â months
[Beginners Corner] - Re: Seam Text: linebreaks in .properties file
by genman
Read the JavaDoc for java.util.Properties:
| Then every entry in this Properties table is written out, one per line. For each entry the key string is written, then an ASCII =, then the associated element string. Each character of the key and element strings is examined to see whether it should be rendered as an escape sequence. The ASCII characters \, tab, form feed, newline, and carriage return are written as \\, \t, \f \n, and \r, respectively. Characters less than \u0020 and characters greater than \u007E are written as \uxxxx for the appropriate hexadecimal value xxxx. For the key, all space characters are written with a preceding \ character. For the element, leading space characters, but not embedded or trailing space characters, are written with a preceding \ character. The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded.
|
So use \r\n
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098587#4098587
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098587
18Â years, 6Â months