On the PlantUML I'm getting syntax errror on the class diagams generated by dcdg on Flutter/Dart. First error is on line 66, how to fix them? Planttext.com or plantuml-editor.kkeisuke.com can be used to show the uml.
#startuml
set namespaceSeparator ::
class "covid19stats::chartsData.dart::ChartsData" {
+ChartData* total
+ChartData* recovered
+ChartData* deaths
+ChartData* vaccine
}
"covid19stats::chartsData.dart::ChartsData" o-- "covid19stats::chartsData.dart::ChartData"
class "covid19stats::chartsData.dart::ChartData" {
+bool* daily
+bool* available
+List<String*>* labels
+List<int*>* values
+List<Color*>* gradientColors
}
class "covid19stats::counter.dart::Counter" {
+Animation<int*>* animation
+TextStyle* textStyle
+Widget* build()
}
"covid19stats::counter.dart::Counter" o-- "flutter::src::animation::animation.dart::Animation<int>"
"covid19stats::counter.dart::Counter" o-- "flutter::src::painting::text_style.dart::TextStyle"
"flutter::src::widgets::transitions.dart::AnimatedWidget" <|-- "covid19stats::counter.dart::Counter"
class "covid19stats::countryData.dart::CountryData" {
+int* totalTests
+int* testsPerMln
+int* totalCases
+double* casesPerMln
+int* newCases
+int* totalRecovered
+int* newRecovered
+int* activeCases
+int* totalDeaths
+double* deathsPerMln
+int* criticalCases
+int* newDeaths
+String* link
+int* vacTotal
+int* vacDaily
+int* vactotalPerHundred
+int* vacdailyPerMillion
}
class "covid19stats::countryDataVac.dart::CountryDataVac" {
+int* vacTotal
+int* vacDaily
+int* vactotalPerHundred
+int* vacdailyPerMillion
+String* date
+Map<String*, dynamic>* toJson()
}
class "covid19stats::dateRangeDialog.dart::DateRangeDialog" {
+DateTimeRange* availableRange
+DateTimeRange* currentRange
+_DateRangeDialogState* createState()
}
"covid19stats::dateRangeDialog.dart::DateRangeDialog" o-- "flutter::src::material::date.dart::DateTimeR
ange"
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::dateRangeDialog.dart::DateR
angeDialog"
class "covid19stats::dateRangeDialog.dart::_DateRangeDialogState" {
+TextEditingController* fromController
+TextEditingController* toController
+DateFormat* dateFormat
+DateTimeRange* selectedRange
+int* selectedOption
+DateTimeRange* preset7
+DateTimeRange* preset28
+void initState()
+Widget* build()
+void checkForPresets()
}
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "flutter::src::widgets::editable_text.d
art::TextEditingController"
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "intl::intl.dart::DateFormat"
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "flutter::src::material::date.dart::Dat
eTimeRange"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::dateRangeDialog.dart::_DateRangeDial
ogState"
class "covid19stats::main.dart::MyApp" {
+Widget* build()
}
"flutter::src::widgets::framework.dart::StatelessWidget" <|-- "covid19stats::main.dart::MyApp"
class "covid19stats::main.dart::MyHomePage" {
+_MyHomePageState* createState()
}
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::main.dart::MyHomePage"
class "covid19stats::main.dart::_MyHomePageState" {
-GlobalKey<State<StatefulWidget*>*>* _refreshIndicatorKey
-GlobalKey<ScaffoldState*>* _scaffoldKey
+Map<String*, CountryData*>* countryData
+Map<String*, CountryDataVac*>* countryDataVac
+Map<String*, ChartsData*>* chartsData
+Map<String*, ChartsData*>* chartsDataVac
+String* country
+bool* justStarted
+int* springAnimationDuration
-AnimationController* _controller
+ThemeData* datePickerTheme
+DateTimeRange* selectedDateRange
+Settings* settings
+void initState()
-void _triggerLiquidPullRefresh()
+Future<void>* refreshData()
+void dispose()
+Widget* build()
+dynamic navigateToSelection()
+Future<void>* showDateDialog()
+Future<void>* showSettingsDialog()
+void checkRangeSetting()
+Widget* createGraph()
}
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::widgets::framework.dart::GlobalKey<State
<StatefulWidget>>"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::widgets::framework.dart::GlobalKey<Scaff
oldState>"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::animation::animation_controller.dart::An
imationController"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::material::theme_data.dart::ThemeData"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::material::date.dart::DateTimeRange"
"covid19stats::main.dart::_MyHomePageState" o-- "covid19stats::settingsDialog.dart::Settings"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::main.dart::_MyHomePageState"
"flutter::src::widgets::ticker_provider.dart::TickerProviderStateMixin" <|-- "covid19stats::main.dart::
_MyHomePageState"
class "covid19stats::parser.dart::Parser" {
{static} +CountryData* parseRow()
{static} +CountryDataVac* parseRowVac()
{static} +int* parseInteger()
{static} +double* parseDouble()
{static} +String* getInnerString()
{static} +String* normalizeName()
{static} +Map<String*, CountryData*>* getCountryData()
{static} +String* capitalize()
{static} +Map<String*, CountryDataVac*>* getCountryDataVac()
{static} +List<String*>* getCategories()
{static} +List<int*>* getDataPoints()
{static} +List<String*>* getVacDates()
{static} +List<int*>* getVacDataPoints()
{static} +ChartsData* getChartsData()
}
class "covid19stats::selectCountry.dart::SelectionScreen" {
+List<dynamic>* countries
+String* selectedCountry
+_SelectionScreenState* createState()
}
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::selectCountry.dart::Selecti
onScreen"
class "covid19stats::selectCountry.dart::_SelectionScreenState" {
+ScrollController* scrollController
+GlobalKey<State<StatefulWidget*>*>* key
+Map<String*, String*>* countryFlags
-TextEditingController* _controller
+FocusNode* textFieldFocusNode
+bool* searchFieldVisible
+List<dynamic>* filteredCountries
+bool* newSearch
+void initState()
+void dispose()
+void toggleSearchField()
+Widget* build()
+Widget* getListTile()
}
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::scroll_controller
.dart::ScrollController"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::framework.dart::G
lobalKey<State<StatefulWidget>>"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::editable_text.dar
t::TextEditingController"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::focus_manager.dar
t::FocusNode"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::selectCountry.dart::_SelectionScreen
State"
class "covid19stats::settingsDialog.dart::Settings" {
+bool* defaultDailyView
+bool* alwaysLoadCharts
+int* rangeSetting
+bool* loaded
+Future<void>* load()
+Future<bool*>* save()
+Settings* clone()
+dynamic []()
}
class "covid19stats::settingsDialog.dart::SettingsDialog" {
+Settings* settings
+_SettingsDialogState* createState()
}
"covid19stats::settingsDialog.dart::SettingsDialog" o-- "covid19stats::settingsDialog.dart::Settings"
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::settingsDialog.dart::Settin
gsDialog"
class "covid19stats::settingsDialog.dart::_SettingsDialogState" {
+Settings* newSettings
+void initState()
+Widget* build()
+Row* getSwitchRow()
}
"covid19stats::settingsDialog.dart::_SettingsDialogState" o-- "covid19stats::settingsDialog.dart::Setti
ngs"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::settingsDialog.dart::_SettingsDialog
State"
class "covid19stats::vaccineCountry.dart::VaccineCountry" {
+String* country
+List<Timeline*>* timeline
+Map<String*, dynamic>* toJson()
}
class "covid19stats::vaccineCountry.dart::Timeline" {
+int* total
+int* daily
+int* totalPerHundred
+int* dailyPerMillion
+String* date
+Map<String*, dynamic>* toJson()
}
class "covid19stats::vaccineData.dart::VaccineData" {
+int* total
+int* daily
+double* totalPerHundred
+double* dailyPerMillion
+String* link
}
#enduml
The first error:
Looks like the issue is caused by the fact that some strings are split over multiple lines (copy / past error or some automatic editor setting at 80(?) characters per line), i.e lines like:
"covid19stats::dateRangeDialog.dart::DateRangeDialog" o-- "flutter::src::material::date.dart::DateTimeR
ange"
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::dateRangeDialog.dart::DateR
angeDialog"
When correcting this, completely, to :
#startuml
set namespaceSeparator ::
class "covid19stats::chartsData.dart::ChartsData" {
+ChartData* total
+ChartData* recovered
+ChartData* deaths
+ChartData* vaccine
}
"covid19stats::chartsData.dart::ChartsData" o-- "covid19stats::chartsData.dart::ChartData"
class "covid19stats::chartsData.dart::ChartData" {
+bool* daily
+bool* available
+List<String*>* labels
+List<int*>* values
+List<Color*>* gradientColors
}
class "covid19stats::counter.dart::Counter" {
+Animation<int*>* animation
+TextStyle* textStyle
+Widget* build()
}
"covid19stats::counter.dart::Counter" o-- "flutter::src::animation::animation.dart::Animation<int>"
"covid19stats::counter.dart::Counter" o-- "flutter::src::painting::text_style.dart::TextStyle"
"flutter::src::widgets::transitions.dart::AnimatedWidget" <|-- "covid19stats::counter.dart::Counter"
class "covid19stats::countryData.dart::CountryData" {
+int* totalTests
+int* testsPerMln
+int* totalCases
+double* casesPerMln
+int* newCases
+int* totalRecovered
+int* newRecovered
+int* activeCases
+int* totalDeaths
+double* deathsPerMln
+int* criticalCases
+int* newDeaths
+String* link
+int* vacTotal
+int* vacDaily
+int* vactotalPerHundred
+int* vacdailyPerMillion
}
class "covid19stats::countryDataVac.dart::CountryDataVac" {
+int* vacTotal
+int* vacDaily
+int* vactotalPerHundred
+int* vacdailyPerMillion
+String* date
+Map<String*, dynamic>* toJson()
}
class "covid19stats::dateRangeDialog.dart::DateRangeDialog" {
+DateTimeRange* availableRange
+DateTimeRange* currentRange
+_DateRangeDialogState* createState()
}
"covid19stats::dateRangeDialog.dart::DateRangeDialog" o-- "flutter::src::material::date.dart::DateTimeRange"
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::dateRangeDialog.dart::DateRangeDialog"
class "covid19stats::dateRangeDialog.dart::_DateRangeDialogState" {
+TextEditingController* fromController
+TextEditingController* toController
+DateFormat* dateFormat
+DateTimeRange* selectedRange
+int* selectedOption
+DateTimeRange* preset7
+DateTimeRange* preset28
+void initState()
+Widget* build()
+void checkForPresets()
}
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "flutter::src::widgets::editable_text.dart::TextEditingController"
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "intl::intl.dart::DateFormat"
"covid19stats::dateRangeDialog.dart::_DateRangeDialogState" o-- "flutter::src::material::date.dart::DateTimeRange"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::dateRangeDialog.dart::_DateRangeDialogState"
class "covid19stats::main.dart::MyApp" {
+Widget* build()
}
"flutter::src::widgets::framework.dart::StatelessWidget" <|-- "covid19stats::main.dart::MyApp"
class "covid19stats::main.dart::MyHomePage" {
+_MyHomePageState* createState()
}
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::main.dart::MyHomePage"
class "covid19stats::main.dart::_MyHomePageState" {
-GlobalKey<State<StatefulWidget*>*>* _refreshIndicatorKey
-GlobalKey<ScaffoldState*>* _scaffoldKey
+Map<String*, CountryData*>* countryData
+Map<String*, CountryDataVac*>* countryDataVac
+Map<String*, ChartsData*>* chartsData
+Map<String*, ChartsData*>* chartsDataVac
+String* country
+bool* justStarted
+int* springAnimationDuration
-AnimationController* _controller
+ThemeData* datePickerTheme
+DateTimeRange* selectedDateRange
+Settings* settings
+void initState()
-void _triggerLiquidPullRefresh()
+Future<void>* refreshData()
+void dispose()
+Widget* build()
+dynamic navigateToSelection()
+Future<void>* showDateDialog()
+Future<void>* showSettingsDialog()
+void checkRangeSetting()
+Widget* createGraph()
}
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::widgets::framework.dart::GlobalKey<State<StatefulWidget>>"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::widgets::framework.dart::GlobalKey<ScaffoldState>"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::animation::animation_controller.dart::AnimationController"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::material::theme_data.dart::ThemeData"
"covid19stats::main.dart::_MyHomePageState" o-- "flutter::src::material::date.dart::DateTimeRange"
"covid19stats::main.dart::_MyHomePageState" o-- "covid19stats::settingsDialog.dart::Settings"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::main.dart::_MyHomePageState"
"flutter::src::widgets::ticker_provider.dart::TickerProviderStateMixin" <|-- "covid19stats::main.dart::_MyHomePageState"
class "covid19stats::parser.dart::Parser" {
{static} +CountryData* parseRow()
{static} +CountryDataVac* parseRowVac()
{static} +int* parseInteger()
{static} +double* parseDouble()
{static} +String* getInnerString()
{static} +String* normalizeName()
{static} +Map<String*, CountryData*>* getCountryData()
{static} +String* capitalize()
{static} +Map<String*, CountryDataVac*>* getCountryDataVac()
{static} +List<String*>* getCategories()
{static} +List<int*>* getDataPoints()
{static} +List<String*>* getVacDates()
{static} +List<int*>* getVacDataPoints()
{static} +ChartsData* getChartsData()
}
class "covid19stats::selectCountry.dart::SelectionScreen" {
+List<dynamic>* countries
+String* selectedCountry
+_SelectionScreenState* createState()
}
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::selectCountry.dart::SelectionScreen"
class "covid19stats::selectCountry.dart::_SelectionScreenState" {
+ScrollController* scrollController
+GlobalKey<State<StatefulWidget*>*>* key
+Map<String*, String*>* countryFlags
-TextEditingController* _controller
+FocusNode* textFieldFocusNode
+bool* searchFieldVisible
+List<dynamic>* filteredCountries
+bool* newSearch
+void initState()
+void dispose()
+void toggleSearchField()
+Widget* build()
+Widget* getListTile()
}
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::scroll_controller.dart::ScrollController"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::framework.dart::GlobalKey<State<StatefulWidget>>"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::editable_text.dart::TextEditingController"
"covid19stats::selectCountry.dart::_SelectionScreenState" o-- "flutter::src::widgets::focus_manager.dart::FocusNode"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::selectCountry.dart::_SelectionScreenState"
class "covid19stats::settingsDialog.dart::Settings" {
+bool* defaultDailyView
+bool* alwaysLoadCharts
+int* rangeSetting
+bool* loaded
+Future<void>* load()
+Future<bool*>* save()
+Settings* clone()
+dynamic []()
}
class "covid19stats::settingsDialog.dart::SettingsDialog" {
+Settings* settings
+_SettingsDialogState* createState()
}
"covid19stats::settingsDialog.dart::SettingsDialog" o-- "covid19stats::settingsDialog.dart::Settings"
"flutter::src::widgets::framework.dart::StatefulWidget" <|-- "covid19stats::settingsDialog.dart::SettingsDialog"
class "covid19stats::settingsDialog.dart::_SettingsDialogState" {
+Settings* newSettings
+void initState()
+Widget* build()
+Row* getSwitchRow()
}
"covid19stats::settingsDialog.dart::_SettingsDialogState" o-- "covid19stats::settingsDialog.dart::Settings"
"flutter::src::widgets::framework.dart::State" <|-- "covid19stats::settingsDialog.dart::_SettingsDialogState"
class "covid19stats::vaccineCountry.dart::VaccineCountry" {
+String* country
+List<Timeline*>* timeline
+Map<String*, dynamic>* toJson()
}
class "covid19stats::vaccineCountry.dart::Timeline" {
+int* total
+int* daily
+int* totalPerHundred
+int* dailyPerMillion
+String* date
+Map<String*, dynamic>* toJson()
}
class "covid19stats::vaccineData.dart::VaccineData" {
+int* total
+int* daily
+double* totalPerHundred
+double* dailyPerMillion
+String* link
}
#enduml
It all works as expected, see also this plantUML diagram
Related
I'm using JSF 2.2 / Mojarra 2.2.8
In my model there are java.util.Set and I want to edit those Set
public class MyModel {
private Set<Foo> fooSet;
private Set<Bar> barSet;
// getters and setters
}
public class Foo {
private String label;
//getter and setter
}
public class Bar {
private String name;
// getter and setter
}
I'm using composite component for that
<h:form>
<ez:editFooSet myModel="#{someBean.myModel}"/>
<ez:editBarSet myModel="#{someBean.myModel}"/>
<!-- ... -->
</h:form>
My idea is to store a List needed by the ui:repeat in a JSF ManagedBean and use a #FacesComponent to convert the Set to List in encodeBegin() and the List to Set in updateModel()
editFooSet.xhtml :
<cc:interface componentType="my.app.component.FooSetComponent">
<cc:attribute name="myModel" type="my.app.model.MyModel" required="true"/>
</cc:interface>
<cc:implementation>
<ui:repeat value="#{fooSetBean.value}" var="item">
<h:outputLabel value="Foo label: "/>
<h:inputText value="#{item.label}"/>
<h:commandButton value="remove" action="#{fooSetBean.remove(item)}"/>
</ui:repeat>
<h:commandButton value="add" action="#{fooSetBean.add()}"/>
</cc:implementation>
FooSetBean.java
#Named
#ViewScoped
public class FooSetBean {
private List<Foo> value;
// getter and setter
puvlic void remove(Foo foo) {
fooList.remove(foo);
}
public void add() {
fooList.add(new Foo());
}
}
and the FooSetComponent.java :
#FacesComponent("my.app.component.FooSetComponent")
public class FooSetComponent extends UIInput implements NamingContainer {
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
#Override
public Object getSubmittedValue() {
return null;
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
MyModel model = (MyModel) super.getAttributes().get("myModel");
Collection<Foo> foos = model.getFooSet();
List<Foo> fooList = new ArrayList<>(foos);
FooSetBean bean = context.getApplication().evaluateExpressionGet(context, "#{fooSetBean}", FooSetBean.class) ;
bean.setValue(fooList);
super.encodeBegin(context);
}
#Override
public void updateModel(FacesContext context) {
MyModel model = (MyModel) super.getAttributes().get("myModel");
FooSetBean bean = context.getApplication().evaluateExpressionGet(context, "#{fooSetBean}", FooSetBean.class) ;
Collection<Foo> newValue = bean.getValue();
model.setFooSet(new HashSet<>(newValue));
}
}
and the same for editBarSet.xhtml, BarSetBean.java and BarSetComponent.java
And that solution is working
My problem is that I have a lot of those Set and I want to factorize this code
I want to have something like that :
<h:form>
<ez:editRepeat value="#{someBean.myModel.fooSet}" itemClass="#{Foo.class}">
<h:outputLabel value="Foo label: "/>
<h:inputText value="#{item.label"/>
</ez:editRepeat>
<ez:editRepeat value="#{someBean.myModel.barSet}" itemClass="#{Bar.class}">
<h:outputLabel value="Bar name: "/>
<h:inputText value="#{item.name}"/>
</ez:editRepeat>
<!-- ... -->
</h:form>
with the editRepeat.xhtml :
<cc:interface componentType="my.app.component.EditRepeatComponent">
<cc:attribute name="value" type="java.util.collection" required="true"/>
<cc:attribute name="itemClass" type="java.lang.Class" required="true"/>
</cc:interface>
<cc:implementation>
<ui:repeat value="#{fooSetBean.value}" var="item" id="repeat">
<cc:insertChildren/>
<h:commandButton value="remove" action="#{cc.remove(item)}"/>
</ui:repeat>
<h:commandButton value="add" action="#{cc.add()}"/>
</cc:implementation>
with a EditRepeatComponent.java
#FacesComponent("my.app.component.EditRepeatComponent")
public class EditRepeatComponent extends UIInput implements NamingContainer {
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
Collection value = (Collection) super.getAttributes().get("value");
List<Foo> list = new ArrayList<>(value);
setList(list);
super.encodeBegin(context);
}
public List getList() {
return (List) getStateHelper().get("list");
}
public void setList(List list) {
getStateHelper().put("list", list);
}
public void add() {
try {
Class itemClass = (Class) super.getAttributes().get("itemClass");
Object newItem = itemClass.newInstance();
getList().add(newItem);
} catch (InstantiationException | IllegalAccessException ex) {
throw new RuntimeException(ex);
}
}
public void remove(Object item) {
getList().remove(item);
}
#Override
public void updateModel(FacesContext context) {
// ???
}
#Override
public Object getSubmittedValue() {
// ???
}
}
But that doesn't work
After a few seconds (the system works during 1 second) I have an exeption :
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:166)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1611)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(FaceletPartialStateManagementStrategy.java:380)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:367)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:585)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:150)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)
at org.omnifaces.viewhandler.RestorableViewHandler.restoreView(RestorableViewHandler.java:86)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:197)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
And I don't understand why
And I don't know yet how to implements updateModel() or getSubmittedValue() to make all the system working
After 2 days I finally succeed
Omnifaces doc http://showcase.omnifaces.org/functions/Converters gave me the solution to deal with ui:repeat : using toArray()
<h:form>
<ez:editRepeat value="#{someBean.myModel.fooSet}" itemClass="my.app.model.Foo">
<h:outputLabel value="Foo label: "/>
<h:inputText value="#{item.label}"/>
</ez:editRepeat>
<ez:editRepeat value="#{someBean.myModel.barSet}" itemClass="my.app.model.Bar">
<h:outputLabel value="Bar name: "/>
<h:inputText value="#{item.name}"/>
</ez:editRepeat>
<!-- ... -->
</h:form>
the editRepeat.xtml (I'm using primefaces p:commanButton to specify update and process attribute so that I don't lose unsubmited input and I don't submit all the form)
<cc:interface>
<cc:attribute name="value" type="java.util.Collection" required="true"/>
<cc:attribute name="itemClass" type="java.lang.String" required="true"/>
</cc:interface>
<cc:implementation>
<h:panelGroup style="display: block; background-color: rgba(200, 200, 200, 0.5); padding: 12px;">
<ui:repeat value="#{cc.attrs.value.toArray()}" var="item">
<h:panelGroup style="background-color: rgba(200, 200, 200, 0.5); margin-left: 12px; margin-bottom: 12px; display: block; padding: 12px;">
<cc:insertChildren/>
<p:commandButton value="remove" action="#{editRepeatBean.remove(cc.attrs.value, item)}"
update="#parent:#parent:#parent" process="#parent:#parent:#parent"
style="margin-left: 12px;"/>
</h:panelGroup>
</ui:repeat>
<p:commandButton value="add" action="#{editRepeatBean.add(cc.attrs.value, cc.attrs.itemClass)}" update="#parent" process="#parent"/>
</h:panelGroup>
</cc:implementation>
the EditRepeatBean.java
#Named
#RequestScoped
public class EditRepeatBean {
public void add(Collection collection, String itemClassName) {
try {
Class itemClass = Class.forName(itemClassName);
Object item = itemClass.newInstance();
collection.add(item);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
public void remove(Collection collection, Object item) {
collection.remove(item);
}
}
and if you have :
public class MyModel {
private Set<Foo> fooSet;
// getter and setter
}
public class Foo {
private String label;
private Set<Bar> barSet;
// getters and setters
}
public class Bar {
private String name;
// getter and setter
}
you can do
<h:form>
<ez:editRepeat value="#{someBean.myModel.fooSet}" itemClass="my.app.model.Foo">
<h:outputLabel value="Foo label: "/>
<h:inputText value="#{item.label}"/>
<ez:editRepeat value="#{item.barSet}" itemClass="my.app.model.Bar">
<h:outputLabel value="Bar name: "/>
<h:inputText value="#{item.name}"/>
</ez:editRepeat>
</ez:editRepeat>
<!-- ... -->
</h:form>
and it's working too
There is still one problem remaining : the Set must not be null, I will edit if I found a solution
EDIT : solution for the null Collection
Just change the editRepeat.xhtml interface to add a componentType so that the collection will be initialize in the encodeBegin() method and add an cc:attribute to secify the implementation of a Collection with a default value to HashSet
<cc:interface componentType="my.app.component.EditRepeatComponent">
<cc:attribute name="value" type="java.util.Collection" required="true"/>
<cc:attribute name="itemClass" type="java.lang.String" required="true"/>
<cc:attribute name="collectionImpl" type="java.lang.String" default="java.util.HashSet"/>
</cc:interface>
and the EditRepeatComponent.java
#FacesComponent("my.app.component.EditRepeatComponent")
public class EditRepeatComponent extends UIInput implements NamingContainer {
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
ELContext elContext = context.getELContext();
ValueExpression valueExpression = super.getValueExpression("value");
if (valueExpression.getValue(elContext) == null) {
try {
String collectionImpl = (String) super.getAttributes().get("collectionImpl");
Class<? extends Collection> collectionClass = (Class<? extends Collection>) Class.forName(collectionImpl);
Collection collection = collectionClass.newInstance();
valueExpression.setValue(elContext, collection);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
super.encodeBegin(context);
}
}
well there is still a problem... when an ez:editRepeat is in an other ez:editRepeat, the remove of the inner ez:editRepeat doesn't work
Caused by: javax.el.PropertyNotFoundException: The class 'my.app.model.Bar' does not have the property 'barSet'
Edit : Final solution.
With the previous solution, there was a problem in nested <editRepeat>, during the processValidators() phase, the var of inner <repeat> components is null, causing a Exception and I don't know why, it's may be a bug...
The solution is to #Override processValidators() and re set the repeat.var.
Here is the complete solution with some improvement :
The component is warpped in an other so that the update of the parent just update the component
All the code of EditRepeatBean has been moved to EditRepeatComponent
Add var attribute
rename attributes for consistency
update/render and process/execute done programmatically
<h:form>
<ez:editRepeat value="#{someBean.myModel.fooSet}"
itemType="my.app.model.Foo"
var="foo">
<h:outputLabel value="Foo label: "/>
<h:inputText value="#{foo.label}"/>
<ez:editRepeat value="#{foo.barSet}"
itemType="my.app.model.Bar"
var="bar">
<h:outputLabel value="Bar name: "/>
<h:inputText value="#{bar.name}"/>
</ez:editRepeat>
</ez:editRepeat>
<!-- ... -->
</h:form>
editRepeat.xhtml (the wrapper) :
<cc:interface>
<cc:attribute name="value" type="java.util.Collection" required="true"/>
<cc:attribute name="itemType" type="java.lang.String" required="true"/>
<cc:attribute name="collectionType" type="java.lang.String" default="java.util.HashSet"/>
<cc:attribute name="var" type="java.lang.String" required="true"/>
</cc:interface>
<cc:implementation>
<h:panelGroup id="#{cc.id}Wrapper">
<ez:editRepeatWrapped value="#{cc.attrs.value}" var="#{cc.attrs.var}"
itemType="#{cc.attrs.itemType}"
collectionType="#{cc.attrs.collectionType}"
id="#{cc.id}Wrapped">
<cc:insertChildren/>
</ez:editRepeatWrapped>
</h:panelGroup>
</cc:implementation>
the editRepeatWrapped.xhtml :
<cc:interface componentType="my.app.component.EditRepeatComponent">
<cc:attribute name="value" type="java.util.Collection" required="true"/>
<cc:attribute name="itemType" type="java.lang.String" required="true"/>
<cc:attribute name="collectionType" type="java.lang.String" default="java.util.HashSet"/>
<cc:attribute name="var" type="java.lang.String" required="true"/>
</cc:interface>
<cc:implementation>
<h:panelGroup id="itemsGroup" style="display: block; background-color: rgba(0, 255, 0, 0.20); padding: 6px; margin: 6px;">
<ui:repeat value="#{cc.attrs.value.toArray()}" var="#{cc.attrs.var}"
id="#{cc.attrs.id}Repeat">
<h:panelGroup id="itemGroup" style="background-color: rgba(0, 255, 0, 0.2); margin-left: 12px; margin: 6px; display: block; padding: 6px;">
<cc:insertChildren/>
<p:commandButton value="remove" action="#{cc.remove()}"
style="margin-left: 12px;"/>
</h:panelGroup>
</ui:repeat>
<p:commandButton value="add" action="#{cc.add()}"/>
</h:panelGroup>
</cc:implementation>
the EditeRepeatComponent.java :
#FacesComponent("my.app.component.EditRepeatComponent")
public class EditRepeatComponent extends UIInput implements NamingContainer {
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
#Override
public void processValidators(FacesContext context) {
initVar(); // because repeat.var is null at this stage
super.processValidators(context);
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
initValue(context);
initVar();
super.encodeBegin(context);
}
/**
* set var of the repeat component
*/
private void initVar() {
String idRepeatComponent = ((String) super.getAttributes().get("id")) + "Repeat";
String var = (String) getAttributes().get("var");
UIRepeat repeatConponent = (UIRepeat) super.findComponent(idRepeatComponent);
repeatConponent.setVar(var);
}
/**
* if the value is null then initialize the collection with the collection type attribute
*/
private void initValue(FacesContext context) {
ELContext elContext = context.getELContext();
ValueExpression valueExpression = super.getValueExpression("value");
Collection collection = (Collection) valueExpression.getValue(elContext);
if (collection == null) {
try {
String collectionType = (String) getAttributes().get("collectionType");
Class<? extends Collection> collectionClass = (Class<? extends Collection>) Class.forName(collectionType);
collection = collectionClass.newInstance();
valueExpression.setValue(elContext, collection);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
}
public void remove() {
String var = (String) getAttributes().get("var");
Object item = evaluate(var);
Collection collection = (Collection) getAttributes().get("value");
collection.remove(item);
updateView();
}
private Object evaluate(String var) {
FacesContext facesContext = getFacesContext();
ELContext elContext = facesContext.getELContext();
Application application = facesContext.getApplication();
ExpressionFactory expressionFactory = application.getExpressionFactory();
ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{" + var + "}", Object.class);
Object item = expression.getValue(elContext);
return item;
}
public void add() {
try {
Collection collection = (Collection) getAttributes().get("value");
String itemType = (String) getAttributes().get("itemType");
Class itemClass = Class.forName(itemType);
Object item = itemClass.newInstance();
collection.add(item);
updateView();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
/**
* render/update and execute/process the wrapper of the component
*/
private void updateView() {
PartialViewContext context = getFacesContext().getPartialViewContext();
String parentId = this.getParent().getClientId();
context.getRenderIds().add(parentId);
context.getExecuteIds().add(parentId);
}
}
Not that <ui:repeat ... var="#{cc.attrs.var}" ...> is useless, the var isn't set that way (and I don't know why...), it is set in the EditRepeatComponent.initVar() during both encodeBegin() and processValidators() I just put var="#{cc.attrs.var}" for the understanding
i'm trying to use the primefaces autoComplete component with POJO.
I know i need a converter. I've successfully used it many time before. But this time i've a special requirement.
I need the POJO only to show many columns to the user, but when it's selected i only want to get one of his property (String), not the POJO itself.
When i've used autoComplete successfully it only with full POJO, I mean : use a list of POJO and on selection also get a POJO (and not only one of his property).
<p:autoComplete
value="#{testBean.selectedA.val2}"
completeMethod="#{testBean.testAutoComplete}"
var="varB"
itemLabel="#{varB.val10}"
itemValue="#{varB.val10}"
forceSelection="true" dropdown="true">
<p:column>
<h:outputText value="#{varB.val10}" />
</p:column>
<p:column>
<h:outputText value="#{varB.val11}" />
</p:column>
</p:autoComplete>
Here testBean.selectedA.val2 is of type String. In fact selectedA is a DTO, so inside all property are of primitive type, or String type, but no other POJO.
varB is a POJO
varB.val10 is of type String.
varB.val11 is of type String.
If in my backing bean testBean.selectedA.val2 is empty/null there is no problem.
Now if i need to initialize this value (testBean.selectedA.val2) in the backing bean to show a value to the user i get one error.
So i don't know how i can put a default value in the String property linked to the autoComplete
INFO [stdout] (default task-15) /test.xhtml #26,42 itemLabel="#{varB.val10}": The class 'java.lang.String' does not have the property 'val10'.
I think my problem is because i use autoComplete with POJO list but only want a String property as a result.
The problem look like this one : Is this a bug in primefaces autocomplete?
Do you have any ideas ?
Is it possible to use autoComplete in this conditions ?
Thank in advance for your help.
Below are some additional informations.
My configuration :
Primefaces 5.1.6
Wildfly 8.1
Full stack trace :
11:00:32,915 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-15) Error Rendering View[/test.xhtml]: javax.el.PropertyNotFoundException: /test.xhtml #26,42 itemLabel="#{varB.val10}": The class 'java.lang.String' does not have the property 'val10'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.2.6-jbossorg-4.jar:]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at org.primefaces.component.autocomplete.AutoComplete.getItemLabel(AutoComplete.java:152) [primefaces-5.1.6.jar:5.1.6]
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeInput(AutoCompleteRenderer.java:189) [primefaces-5.1.6.jar:5.1.6]
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeSingleMarkup(AutoCompleteRenderer.java:146) [primefaces-5.1.6.jar:5.1.6]
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeMarkup(AutoCompleteRenderer.java:129) [primefaces-5.1.6.jar:5.1.6]
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeEnd(AutoCompleteRenderer.java:107) [primefaces-5.1.6.jar:5.1.6]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) [jsf-impl-2.2.6-jbossorg-4.jar:]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:461) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133) [jsf-impl-2.2.6-jbossorg-4.jar:]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) [jsf-impl-2.2.6-jbossorg-4.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at fr.legrain.solstyce.webapp.AuthFilter.doFilter(AuthFilter.java:65) [classes:]
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
Caused by: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'val10'.
at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:731) [jboss-el-api_3.0_spec-1.0.3.Final.jar:1.0.3.Final]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:351) [jboss-el-api_3.0_spec-1.0.3.Final.jar:1.0.3.Final]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.2.6-jbossorg-4.jar:]
at com.sun.el.parser.AstValue.getValue(AstValue.java:140) [javax.el-3.0.0.jar:]
at com.sun.el.parser.AstValue.getValue(AstValue.java:204) [javax.el-3.0.0.jar:]
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) [javax.el-3.0.0.jar:]
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.5.Final.jar:2014-09-15 07:54]
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.5.Final.jar:2014-09-15 07:54]
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.2.6-jbossorg-4.jar:]
... 56 more
I've tried to make here a simple example to show my problem.
The view test.xhtml :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Test</title>
</h:head>
<h:body>
<h:panelGrid columns="2" cellpadding="10">
<p:outputLabel value="A.val1 : " />
<p:inputText value="#{testBean.selectedA.val1}"/>
<p:outputLabel value="A.val2 : " />
<p:autoComplete
value="#{testBean.selectedA.val2}"
completeMethod="#{testBean.testAutoComplete}"
var="varB"
itemLabel="#{varB.val10}"
itemValue="#{varB.val10}"
forceSelection="true" dropdown="true">
<p:column>
<h:outputText value="#{varB.val10}" />
</p:column>
<p:column>
<h:outputText value="#{varB.val11}" />
</p:column>
</p:autoComplete>
</h:panelGrid>
</h:body>
</html>
The managed bean TestBean.java:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class TestBean implements Serializable {
private static final long serialVersionUID = 7752061447417566324L;
private A selectedA;
private BService bService;
#PostConstruct
public void init() {
bService = new BService();
selectedA = new A();
selectedA.setVal1("xxx");
selectedA.setVal2("bb2"); //comment this line and there is no more problem
}
public List<B> testAutoComplete(String query) {
List<B> allValues = bService.getAllValues();
List<B> filteredValues = new ArrayList<B>();
if(query==null || query.equals("")) {
return allValues;
} else {
for (int i = 0; i < allValues.size(); i++) {
B b = allValues.get(i);
if(b.getVal10().toLowerCase().contains(query.toLowerCase())) {
filteredValues.add(b);
}
}
return filteredValues;
}
}
public A getSelectedA() {
return selectedA;
}
public void setSelectedA(A selectedA) {
this.selectedA = selectedA;
}
}
The service BService.java :
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class BService implements Serializable {
private static final long serialVersionUID = -7442506301755842723L;
private static final List<B> allValues = new ArrayList<B>();
public BService() {
init();
}
public void init() {
if(allValues.isEmpty()) {
allValues.add(new B("aa1", "ab"));
allValues.add(new B("bb2", "abc"));
allValues.add(new B("ab3", "abcd"));
}
}
public List<B> getAllValues() {
return allValues;
}
}
The converter BConverter.java :
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
#FacesConverter(forClass=B.class)
public class BConverter implements Converter {
private BService bService = new BService();
#Override
public String getAsString(FacesContext context, UIComponent component, Object valueToRender) {
if (valueToRender == null || valueToRender.equals("")) {
return "";
} else {
return String.valueOf(((B) valueToRender).getVal10());
}
}
#Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
if (submittedValue.trim().equals("")) {
return null;
} else {
try {
//int number = Integer.parseInt(submittedValue);
return bService.getAllValues().get(bService.getAllValues().indexOf(submittedValue));
} catch (Exception e) {
e.printStackTrace();
}
}
return submittedValue;
}
}
The class A.java :
public class A {
private String val1;
private String val2;
public A() {
}
public A(String val1, String val2) {
super();
this.val1 = val1;
this.val2 = val2;
}
public String getVal1() {
return val1;
}
public void setVal1(String val1) {
this.val1 = val1;
}
public String getVal2() {
return val2;
}
public void setVal2(String val2) {
this.val2 = val2;
}
}
The class B.java :
public class B {
private String val10;
private String val11;
public B() {
}
public B(String val10, String val11) {
super();
this.val10 = val10;
this.val11 = val11;
}
public String getVal10() {
return val10;
}
public void setVal10(String val10) {
this.val10 = val10;
}
public String getVal11() {
return val11;
}
public void setVal11(String val11) {
this.val11 = val11;
}
}
Your problem is here:
The class 'java.lang.String' does not have the property 'val10'. it mean that you have value of type String and you try to get property val10 from this String which doesn't exist.
Your code has a mistake itemValue="#{varB.val10}" should be replaced by itemValue="#{varB}", and itemLabel="#{varB.val10}" can be eliminated because you use:
`<p:column>
<h:outputText value="#{varB.val10}" />
</p:column>
<p:column>
<h:outputText value="#{varB.val11}" />
</p:column>`
To display values. Consider rewrite your code in such way:
<p:autoComplete
value="#{testBean.selectedA.val2}"
completeMethod="#{testBean.testAutoComplete}"
var="varB"
itemValue="#{varB}"
forceSelection="true" dropdown="true">
<p:column>
<h:outputText value="#{varB.val10}" />
</p:column>
<p:column>
<h:outputText value="#{varB.val11}" />
</p:column>
</p:autoComplete>
And value="#{testBean.selectedA.val2}" should pointing to the object of same type which you get from autocomplete method.
I have simple javafx application that hangs when resizing.
Application was compiled/build with jdk1.7.0_10
OS: Windows 8
IDE: NetBeans 7.2.1
The problem occurs when I populate bottom table and start resizing by shifting the right border of application. Sometimes I need to play with resizing for a while, shifting inner borders of SplitPanes and external application borders till it collapses. When the row is empty, that is nothing is populated in the table, then everything works fine - no hangings, I can resize in every direction whatever I want - and nothing hangs.
Application hangs and ends with Java Result: 255 in Netbeans Output Window.
What could it be? There are no logs, exceptions, nothing...it drives me mad, lost so much time on it :(
Here is my controller:
public class MyFXMLController implements Initializable {
#FXML
TableView<Person> table;
#FXML
TableColumn<Person, String> firstNameCol;
#FXML
TableColumn<Person, String> lastNameCol;
#FXML
TableColumn<Person, String> carCol;
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
carCol.setCellValueFactory(new PropertyValueFactory("car"));
Person p1 = new Person();
p1.setFirstName("A");
p1.setLastName("B");
p1.setCar("ferrari");
ObservableList<Person> teamMembers = FXCollections.observableArrayList(p1);
table.setItems(teamMembers);
}
}
Main class is:
public class TestTableView extends Application {
#Override
public void start(Stage primaryStage) {
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
AnchorPane page = null;
try {
page = (AnchorPane) FXMLLoader.load(TestTableView.class.getResource("/testtableview/myFXML.fxml"));
} catch (IOException ex) {
Logger.getLogger(TestTableView.class.getName()).log(Level.SEVERE, null, ex);
}
Scene scene = new Scene(page);
primaryStage.setScene(scene);
primaryStage.setTitle("my");
primaryStage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
and FXML file used:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="715.0000999999975" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml" fx:controller="testtableview.MyFXMLController">
<children>
<SplitPane dividerPositions="0.22720894429047145" focusTraversable="true" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TreeView prefHeight="398.0" prefWidth="159.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<SplitPane dividerPositions="0.5" focusTraversable="true" orientation="VERTICAL" prefHeight="398.0" prefWidth="491.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<TableView id="table" prefHeight="195.0" prefWidth="489.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X">
<columns>
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
</columns>
</TableColumn>
<TableColumn prefWidth="75.0" text="Column X">
<columns>
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
</columns>
</TableColumn>
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
</columns>
</TableView>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<TableView fx:id="table" prefHeight="195.0" prefWidth="489.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn prefWidth="75.0" text="firstNameCol" fx:id="firstNameCol" />
<TableColumn prefWidth="75.0" text="lastNameCol" fx:id="lastNameCol" />
<TableColumn prefWidth="75.0" text="carCol" fx:id="carCol" />
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
</columns>
</TableView>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
<stylesheets>
<URL value="#myfxml.css" />
</stylesheets>
</AnchorPane>
And underlying data class is:
package testtableview;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Person {
private StringProperty firstName;
public void setFirstName(String value) {
firstNameProperty().set(value);
}
public String getFirstName() {
return firstNameProperty().get();
}
public StringProperty firstNameProperty() {
if (firstName == null) {
firstName = new SimpleStringProperty(this, "firstName");
}
return firstName;
}
private StringProperty lastName;
public void setLastName(String value) {
lastNameProperty().set(value);
}
public String getLastName() {
return lastNameProperty().get();
}
public StringProperty lastNameProperty() {
if (lastName == null) {
lastName = new SimpleStringProperty(this, "lastName");
}
return lastName;
}
private StringProperty car;
public void setCar(String value) {
carProperty().set(value);
}
public String getCar() {
return carProperty().get();
}
public StringProperty carProperty() {
if (car == null) {
car = new SimpleStringProperty(this, "car");
}
return car;
}
}
However I am not able to see any specific problem here. but it might be problem with your memory management. try to make data class static as a subclass in controller class.
So I'm very new to JSF, I just started using it a few days ago and I'm trying to learn off of youtube tutorials and a couple of books. But I can't tell why this isn't working. Here's my code:
<h:form styleClass="formStyle">
<h1>Log In</h1>
<fieldset id="inputs">
<h:inputText id="username" type="text" value="#{redirectBean.name}">
</h:inputText>
<h:inputSecret id="password" type="password" value="#{redirectBean.password}">
</h:inputSecret>
</fieldset>
<fieldset id="actions">
<h:button type="submit" styleClass="test" value="Log in" outcome="#{redirectBean.login}">
</h:button>
</fieldset>
</h:form>
redirectBean.java is simply a class containing 3 private strings (login="welcome", name and password) and their getters/setters.
Upon clicking the Login button I am redirected to welcome.xhtml but there are no changes made to redirectBean.name or redirectBean.password.
Any thoughts? What am I missing?
Edit: so BalusC has explained that I need to use h:commandButton instead, but that wasn't redirecting me. After some back-and-forth trying to figure out why, this is the server log I'm currently getting (It's redirecting me now with the command button but still not passing the value to the bean. I also got something about RI and MyFaces conflicting, but some tinkering in the classpath seems to have fixed that):
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5332)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498) at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener at
org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2743)
at
org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:1966)
at
com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:235)
at
com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:94)
at
com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:274)
at
com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:172)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5329)
... 39 more Caused by: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at
org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:4806)
at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1599)
at
org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2740)
... 46 more
WARNING: java.lang.IllegalStateException: ContainerBase.addChild:
start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
SEVERE: Exception while invoking class
com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
SEVERE: Exception while loading the app SEVERE: Exception while
loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener
You need to use <h:commandButton>, not <h:button>. The <h:button> merely sends a GET request, while the <h:commandButton> submits the form by POST.
<h:commandButton styleClass="test" value="Log in" action="#{redirectBean.login}" />
with
public String login() {
// Do your business job.
return "welcome";
}
See also:
Our JSF tag wiki page - contains some Hello World examples and good tutorial links
Im trying to populate a JSF Datatable with data that I am retrieving from a DynamoDB Table (The Amazon NoSQL DB). At the moment everything is working fine right up to the Iteration over the scanResults. The debugger shows that my scanResult has a list of all the accounts but when I try to iterate over those results in order to construct my List nothing seems to be added to the allUserSummary List and I end up with a nullpointer exception.
The basic User POJO:
public class User {
private String uuid;
public User(String uuid) {
this.uuid = uuid;
}
}
The managed bean:
private List<User> allUserSummary;
private List<String> uuid;
private User selectedUser;
public List<User> getAllUserSummary() throws Exception {
populateData();
return allUserSummary;
}
private void populateData() throws Exception {
// Create a new AmazonDynamoDBClient and mapper
AmazonDynamoDBClient client = dynamoClient.getDynamoClient();
DynamoDBMapper mapper = new DynamoDBMapper(client);
try {
// Create a new scan expression and filter to find the required data from the db
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition scanCondition = new Condition().withComparisonOperator(ComparisonOperator.NOT_NULL);
scanFilter.put("uuid", scanCondition);
scanExpression.setScanFilter(scanFilter);
// Run the scan
List scanResults = mapper.scan(UserAccounts.class, scanExpression);
// Iterate over the scanned results and add the required data to a new User
for (Iterator it = scanResults.iterator(); it.hasNext();) {
allUserSummary.add(new User(scanResults.get(1).toString()));
}
} catch (Exception e) {
// TODO
}
}
The Datatable (Im using primefaces but the problem is the same with standard JSF DT):
<h:form>
<pou:dataTable id="users"
var="user"
value="#{accountManager.allUserSummary}"
paginator="true"
rows="10"
selection="#{accountManager.selectedUser}">
<f:facet name="header">
UUID
</f:facet>
<pou:column selectionMode="multiple" />
<pou:column headerText="Uuid">
#{user.uuid}
</pou:column>
<f:facet name="footer">
<pou:commandButton id="multiViewButton"
value="View"
icon="ui-icon-search"
update=""
oncomplete=""/>
</f:facet>
</pou:dataTable>
</h:form>
STACK TRACE:
java.lang.IllegalArgumentException: ""
at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:570)
at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:244)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at org.primefaces.component.datatable.DataTableRenderer.encodeFacet(DataTableRenderer.java:839)
at org.primefaces.component.datatable.DataTableRenderer.encodeTFoot(DataTableRenderer.java:823)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:247)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:224)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:108)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
here you go...
Set values into update="" and oncomplete="" or remove them from your button...
<pou:commandButton id="multiViewButton"
value="View"
icon="ui-icon-search"
update=""
oncomplete=""/>
EDIT
try the following changes :
private List<User> allUserSummary = new ArrayList<User>();
.
.
.
#PostConstruct
public void populateData() throws Exception {
.
.
.
.
public List<User> getAllUserSummary() throws Exception {
return allUserSummary;
}