How to set DropDownChoice selected at particular index/choicedata in apache wicket? - wicket

Hi I have created DropDownChoice component of apache wicket. now what I want to do is that after component creation I want to set some choice as a default selected based on certain condition. I am not getting it anyhow. Anyone can plz help me out.
Thanks in advance.

If you need to select multiple options then you should use org.apache.wicket.markup.html.form.ListMultipleChoice#ListMultipleChoice(java.lang.String, org.apache.wicket.model.IModel<? extends java.util.Collection<T>>, org.apache.wicket.model.IModel<? extends java.util.List<? extends T>>). The first model holds the selections, and the second holds all possible options.

Related

Autodesk forge highlight child object

Recently i've been working on this repository https://github.com/xiaodongliang/forgeviewer_embed_in_powerbi_report to build a custom visual in Power BI to visualize the issues extracted from Bim track'S API.
The idea was visualizing them in associaton to the model's ROOMS.
In order to do that I worked with a NWC file, so i cuold export rooms as a geometry.
What i would like to do now is to highligt the rooms if a connected issue is selected from a table.
The problem is When i select an issue from a table, in the selection tree i can see highlighted the parent object name (ROOM) instead of the child (solid), and i think that is why i can't achieve my purpose (if not please correct me).
what i have
what i wold like to do
Does anyone know a way to do that?
If you would like to change your selection between (FIRST_OBJECT, LAST_OBJECT, LEAF_OBJECT) you can change viewer selection settings in order to test:
If you would like to achieve this programmatically :
Viewer.setSelectionMode();
could help you as well.
If I well understood, you want to highlight the child (which contain the mesh) instead of the parent.
The object highlight (isolate) is done in /forgePowerbiView/src/visual.ts with this code:
const dbIds = options.dataViews[0].table.rows.map(r =>
<number>r[0].valueOf());
console.log('dbIds: ' +dbIds)
this.forge_viewer.showAll();
this.forge_viewer.impl.setGhostingBrightness(true); //for isolate effect
this.forge_viewer.isolate(dbIds);
Take a look at this link Enumerating leaf nodes on Viewer. This will help you to get the dbIds you want to isolate.

How to display a custom attribute on Cart Page in hybris?

I have a custom attribute whose value I have to display for every item in the cart on the Cart Page. I want to add the attribute in cartItem.tag. Can someone please tell me where should I add the value? I tried adding it in the CartPageController, but could not find an appropriate place to add the value.
I'm completely new to Hybris, any help would be appreciated.
Thanks, in advance.
I am guessing this new attribute belongs to the OrderEntryData type. You can use or create some Populator to add value to this attribute. You should use populators when you want to copy some value from modelObject to dataObject in order to show it whithin the presentantion layer.
Steps you need to follow:
Add new attribute on CartEntryModel at item level where, your new attribute value will get store on model
Add new attribute in CartData using **beans.xml, which will hold and show value on cart page
Create new custom populator by extending commercefacades's "CartPopulator" and populate new attribute value
Finally, you can use new attribute directly on cartPage via. cartEntry.newAttribute

With setResponsePage, how can I add the page version of the page I want?

With setReponsePage, how can I add the page version of the page I want? So for example 3 in http://localhost:8080/wicket-testing/?3.
Thanks.
You need to use #setResponsePage(Page) instead, not #setResponsePage(Class).
First you need to get a reference to the page with that id: session.getPageManager().getPage(pageId).
Are you confusing wicket pages (where the constructor does not need a wicket-id) with panels (where you have to provide a wicket-id)?
setResponsePage itself accepts either a class (with optional PageParameters) or an instance as a parameter:
setResponsePage(DestinationPage.class);
setResponsePage(DestinationPageWithPageParameters.class, new PageParameters().add("id", 42));
setResponsePage(new DestinationPageWithConstructorParameters(param1, param2));
If you are talking about panels (e.g. MyPanel(String wicketId)) then you need to embed this panel into a wicket page because you cannot pass a panel to setReponsePage.

Event listener on select field in Symfony 1.4

I got two select fields in my symfony project: ContrySelect and StateSelect. They are implemented with the sfDependentSelectPlugin. I just want to know if does it exist a way to listen to the events of the CountrySelect so I can set or unset the StateSelect field.
Thanks in advance.
I only worked once with this plugin.
It has an option for the sfWidgetFormDependentSelect which is called 'ajax'.
See doc:
ajax = false: Specifies whether remote calls are used to populate the
select values,
This may be an option.
Otherwise I would advise you to just create a custom javascript listener on your CountrySelect that will set the other widget.

How to remove a validator from a Select?

I have a form where I need to add/remove validators dynamically. Based on a dropdown selection, other form fields may have different validation rules.
For other kinds of inputs, I've used replace(methodThatCreatesTheInput()) to get rid of a previously added validator. (Not knowing of a better way. Specifically, there doesn't seem to be any way to directly remove a validator from a component...)
With Select, from wicket-extensions, this approach fails with something like:
WicketMessage: submitted http post value [[Ljava.lang.String;#5b4bf56d]
for SelectOption component [8:myForm:targetInput] contains an
illegal relative path element [targetConsortiums:1:option] which does not
point to an SelectOption component. Due to this the Select component cannot
resolve the selected SelectOption component pointed to by the illegal value.
A possible reason is that component hierarchy changed between rendering and
form submission.
The method that creates the Select:
private FormComponent<?> targetSelection() {
Map<Class<? extends Target>, List<Target>> targets = targetService.getAllAsMap();
SelectOptions<Target> propertyOptions = new SelectOptions<Target>("targetConsortiums",
targets.get(Consortium.class), new TargetRenderer());
SelectOptions<Target> consortiumOptions = new SelectOptions<Target>("targetProperties",
targets.get(Property.class), new TargetRenderer());
Select select = new Select(ID_TARGET, new PropertyModel<Target>(model, "target"));
select.add(propertyOptions);
select.add(consortiumOptions);
select.setRequired(true);
select.setMarkupId(ID_TARGET);
return select;
}
(Why use a Select instead of normal DropDownChoice? We want the two types of choices to be clearly separated, as documented in this question.)
Any ideas how to solve this? What I'm trying to achieve is, of course, very simple. Unfortunately Wicket disagrees, or I'm using it wrong.
Wicket 1.4.
I don't know how to do this on Wicket 1.4, but on Wicket 1.5 there is a remove method for validators on FormComponent (see javadoc)